Commit 6672efbb authored by Khadija Kamran's avatar Khadija Kamran Committed by Paul Moore

lsm: constify the 'target' parameter in security_capget()

Three LSMs register the implementations for the "capget" hook: AppArmor,
SELinux, and the normal capability code. Looking at the function
implementations we may observe that the first parameter "target" is not
changing.

Mark the first argument "target" of LSM hook security_capget() as
"const" since it will not be changing in the LSM hook.

cap_capget() LSM hook declaration exceeds the 80 characters per line
limit. Split the function declaration to multiple lines to decrease the
line length.
Signed-off-by: default avatarKhadija Kamran <kamrankhadijadj@gmail.com>
Acked-by: default avatarJohn Johansen <john.johansen@canonical.com>
[PM: align the cap_capget() declaration, spelling fixes]
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent bd1f5934
...@@ -36,7 +36,7 @@ LSM_HOOK(int, 0, binder_transfer_file, const struct cred *from, ...@@ -36,7 +36,7 @@ LSM_HOOK(int, 0, binder_transfer_file, const struct cred *from,
LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child, LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child,
unsigned int mode) unsigned int mode)
LSM_HOOK(int, 0, ptrace_traceme, struct task_struct *parent) LSM_HOOK(int, 0, ptrace_traceme, struct task_struct *parent)
LSM_HOOK(int, 0, capget, struct task_struct *target, kernel_cap_t *effective, LSM_HOOK(int, 0, capget, const struct task_struct *target, kernel_cap_t *effective,
kernel_cap_t *inheritable, kernel_cap_t *permitted) kernel_cap_t *inheritable, kernel_cap_t *permitted)
LSM_HOOK(int, 0, capset, struct cred *new, const struct cred *old, LSM_HOOK(int, 0, capset, struct cred *new, const struct cred *old,
const kernel_cap_t *effective, const kernel_cap_t *inheritable, const kernel_cap_t *effective, const kernel_cap_t *inheritable,
......
...@@ -145,7 +145,8 @@ extern int cap_capable(const struct cred *cred, struct user_namespace *ns, ...@@ -145,7 +145,8 @@ extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz); extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode); extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
extern int cap_ptrace_traceme(struct task_struct *parent); extern int cap_ptrace_traceme(struct task_struct *parent);
extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); extern int cap_capget(const struct task_struct *target, kernel_cap_t *effective,
kernel_cap_t *inheritable, kernel_cap_t *permitted);
extern int cap_capset(struct cred *new, const struct cred *old, extern int cap_capset(struct cred *new, const struct cred *old,
const kernel_cap_t *effective, const kernel_cap_t *effective,
const kernel_cap_t *inheritable, const kernel_cap_t *inheritable,
...@@ -271,7 +272,7 @@ int security_binder_transfer_file(const struct cred *from, ...@@ -271,7 +272,7 @@ int security_binder_transfer_file(const struct cred *from,
const struct cred *to, struct file *file); const struct cred *to, struct file *file);
int security_ptrace_access_check(struct task_struct *child, unsigned int mode); int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
int security_ptrace_traceme(struct task_struct *parent); int security_ptrace_traceme(struct task_struct *parent);
int security_capget(struct task_struct *target, int security_capget(const struct task_struct *target,
kernel_cap_t *effective, kernel_cap_t *effective,
kernel_cap_t *inheritable, kernel_cap_t *inheritable,
kernel_cap_t *permitted); kernel_cap_t *permitted);
...@@ -553,7 +554,7 @@ static inline int security_ptrace_traceme(struct task_struct *parent) ...@@ -553,7 +554,7 @@ static inline int security_ptrace_traceme(struct task_struct *parent)
return cap_ptrace_traceme(parent); return cap_ptrace_traceme(parent);
} }
static inline int security_capget(struct task_struct *target, static inline int security_capget(const struct task_struct *target,
kernel_cap_t *effective, kernel_cap_t *effective,
kernel_cap_t *inheritable, kernel_cap_t *inheritable,
kernel_cap_t *permitted) kernel_cap_t *permitted)
......
...@@ -112,7 +112,7 @@ static inline int cap_get_target_pid(pid_t pid, kernel_cap_t *pEp, ...@@ -112,7 +112,7 @@ static inline int cap_get_target_pid(pid_t pid, kernel_cap_t *pEp,
int ret; int ret;
if (pid && (pid != task_pid_vnr(current))) { if (pid && (pid != task_pid_vnr(current))) {
struct task_struct *target; const struct task_struct *target;
rcu_read_lock(); rcu_read_lock();
......
...@@ -144,7 +144,7 @@ static int apparmor_ptrace_traceme(struct task_struct *parent) ...@@ -144,7 +144,7 @@ static int apparmor_ptrace_traceme(struct task_struct *parent)
} }
/* Derived from security/commoncap.c:cap_capget */ /* Derived from security/commoncap.c:cap_capget */
static int apparmor_capget(struct task_struct *target, kernel_cap_t *effective, static int apparmor_capget(const struct task_struct *target, kernel_cap_t *effective,
kernel_cap_t *inheritable, kernel_cap_t *permitted) kernel_cap_t *inheritable, kernel_cap_t *permitted)
{ {
struct aa_label *label; struct aa_label *label;
......
...@@ -197,7 +197,7 @@ int cap_ptrace_traceme(struct task_struct *parent) ...@@ -197,7 +197,7 @@ int cap_ptrace_traceme(struct task_struct *parent)
* This function retrieves the capabilities of the nominated task and returns * This function retrieves the capabilities of the nominated task and returns
* them to the caller. * them to the caller.
*/ */
int cap_capget(struct task_struct *target, kernel_cap_t *effective, int cap_capget(const struct task_struct *target, kernel_cap_t *effective,
kernel_cap_t *inheritable, kernel_cap_t *permitted) kernel_cap_t *inheritable, kernel_cap_t *permitted)
{ {
const struct cred *cred; const struct cred *cred;
......
...@@ -894,7 +894,7 @@ int security_ptrace_traceme(struct task_struct *parent) ...@@ -894,7 +894,7 @@ int security_ptrace_traceme(struct task_struct *parent)
* *
* Return: Returns 0 if the capability sets were successfully obtained. * Return: Returns 0 if the capability sets were successfully obtained.
*/ */
int security_capget(struct task_struct *target, int security_capget(const struct task_struct *target,
kernel_cap_t *effective, kernel_cap_t *effective,
kernel_cap_t *inheritable, kernel_cap_t *inheritable,
kernel_cap_t *permitted) kernel_cap_t *permitted)
......
...@@ -2082,7 +2082,7 @@ static int selinux_ptrace_traceme(struct task_struct *parent) ...@@ -2082,7 +2082,7 @@ static int selinux_ptrace_traceme(struct task_struct *parent)
SECCLASS_PROCESS, PROCESS__PTRACE, NULL); SECCLASS_PROCESS, PROCESS__PTRACE, NULL);
} }
static int selinux_capget(struct task_struct *target, kernel_cap_t *effective, static int selinux_capget(const struct task_struct *target, kernel_cap_t *effective,
kernel_cap_t *inheritable, kernel_cap_t *permitted) kernel_cap_t *inheritable, kernel_cap_t *permitted)
{ {
return avc_has_perm(current_sid(), task_sid_obj(target), return avc_has_perm(current_sid(), task_sid_obj(target),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment