Commit 200ac532 authored by Eric Paris's avatar Eric Paris Committed by James Morris

SELinux: call capabilities code directory

For cleanliness and efficiency remove all calls to secondary-> and instead
call capabilities code directly.  capabilities are the only module that
selinux stacks with and so the code should not indicate that other stacking
might be possible.
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
Acked-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent b53fab9d
...@@ -1841,7 +1841,7 @@ static int selinux_ptrace_may_access(struct task_struct *child, ...@@ -1841,7 +1841,7 @@ static int selinux_ptrace_may_access(struct task_struct *child,
{ {
int rc; int rc;
rc = secondary_ops->ptrace_may_access(child, mode); rc = cap_ptrace_may_access(child, mode);
if (rc) if (rc)
return rc; return rc;
...@@ -1858,7 +1858,7 @@ static int selinux_ptrace_traceme(struct task_struct *parent) ...@@ -1858,7 +1858,7 @@ static int selinux_ptrace_traceme(struct task_struct *parent)
{ {
int rc; int rc;
rc = secondary_ops->ptrace_traceme(parent); rc = cap_ptrace_traceme(parent);
if (rc) if (rc)
return rc; return rc;
...@@ -1874,7 +1874,7 @@ static int selinux_capget(struct task_struct *target, kernel_cap_t *effective, ...@@ -1874,7 +1874,7 @@ static int selinux_capget(struct task_struct *target, kernel_cap_t *effective,
if (error) if (error)
return error; return error;
return secondary_ops->capget(target, effective, inheritable, permitted); return cap_capget(target, effective, inheritable, permitted);
} }
static int selinux_capset(struct cred *new, const struct cred *old, static int selinux_capset(struct cred *new, const struct cred *old,
...@@ -1884,7 +1884,7 @@ static int selinux_capset(struct cred *new, const struct cred *old, ...@@ -1884,7 +1884,7 @@ static int selinux_capset(struct cred *new, const struct cred *old,
{ {
int error; int error;
error = secondary_ops->capset(new, old, error = cap_capset(new, old,
effective, inheritable, permitted); effective, inheritable, permitted);
if (error) if (error)
return error; return error;
...@@ -1907,7 +1907,7 @@ static int selinux_capable(struct task_struct *tsk, const struct cred *cred, ...@@ -1907,7 +1907,7 @@ static int selinux_capable(struct task_struct *tsk, const struct cred *cred,
{ {
int rc; int rc;
rc = secondary_ops->capable(tsk, cred, cap, audit); rc = cap_capable(tsk, cred, cap, audit);
if (rc) if (rc)
return rc; return rc;
...@@ -2033,7 +2033,7 @@ static int selinux_syslog(int type) ...@@ -2033,7 +2033,7 @@ static int selinux_syslog(int type)
{ {
int rc; int rc;
rc = secondary_ops->syslog(type); rc = cap_syslog(type);
if (rc) if (rc)
return rc; return rc;
...@@ -2064,10 +2064,6 @@ static int selinux_syslog(int type) ...@@ -2064,10 +2064,6 @@ static int selinux_syslog(int type)
* mapping. 0 means there is enough memory for the allocation to * mapping. 0 means there is enough memory for the allocation to
* succeed and -ENOMEM implies there is not. * succeed and -ENOMEM implies there is not.
* *
* Note that secondary_ops->capable and task_has_perm_noaudit return 0
* if the capability is granted, but __vm_enough_memory requires 1 if
* the capability is granted.
*
* Do not audit the selinux permission check, as this is applied to all * Do not audit the selinux permission check, as this is applied to all
* processes that allocate mappings. * processes that allocate mappings.
*/ */
...@@ -2094,7 +2090,7 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm) ...@@ -2094,7 +2090,7 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
struct inode *inode = bprm->file->f_path.dentry->d_inode; struct inode *inode = bprm->file->f_path.dentry->d_inode;
int rc; int rc;
rc = secondary_ops->bprm_set_creds(bprm); rc = cap_bprm_set_creds(bprm);
if (rc) if (rc)
return rc; return rc;
...@@ -2211,7 +2207,7 @@ static int selinux_bprm_secureexec(struct linux_binprm *bprm) ...@@ -2211,7 +2207,7 @@ static int selinux_bprm_secureexec(struct linux_binprm *bprm)
PROCESS__NOATSECURE, NULL); PROCESS__NOATSECURE, NULL);
} }
return (atsecure || secondary_ops->bprm_secureexec(bprm)); return (atsecure || cap_bprm_secureexec(bprm));
} }
extern struct vfsmount *selinuxfs_mount; extern struct vfsmount *selinuxfs_mount;
...@@ -3312,7 +3308,7 @@ static int selinux_task_setnice(struct task_struct *p, int nice) ...@@ -3312,7 +3308,7 @@ static int selinux_task_setnice(struct task_struct *p, int nice)
{ {
int rc; int rc;
rc = secondary_ops->task_setnice(p, nice); rc = cap_task_setnice(p, nice);
if (rc) if (rc)
return rc; return rc;
...@@ -3323,7 +3319,7 @@ static int selinux_task_setioprio(struct task_struct *p, int ioprio) ...@@ -3323,7 +3319,7 @@ static int selinux_task_setioprio(struct task_struct *p, int ioprio)
{ {
int rc; int rc;
rc = secondary_ops->task_setioprio(p, ioprio); rc = cap_task_setioprio(p, ioprio);
if (rc) if (rc)
return rc; return rc;
...@@ -3353,7 +3349,7 @@ static int selinux_task_setscheduler(struct task_struct *p, int policy, struct s ...@@ -3353,7 +3349,7 @@ static int selinux_task_setscheduler(struct task_struct *p, int policy, struct s
{ {
int rc; int rc;
rc = secondary_ops->task_setscheduler(p, policy, lp); rc = cap_task_setscheduler(p, policy, lp);
if (rc) if (rc)
return rc; return rc;
...@@ -4749,7 +4745,7 @@ static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb) ...@@ -4749,7 +4745,7 @@ static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)
{ {
int err; int err;
err = secondary_ops->netlink_send(sk, skb); err = cap_netlink_send(sk, skb);
if (err) if (err)
return err; return err;
...@@ -4764,7 +4760,7 @@ static int selinux_netlink_recv(struct sk_buff *skb, int capability) ...@@ -4764,7 +4760,7 @@ static int selinux_netlink_recv(struct sk_buff *skb, int capability)
int err; int err;
struct avc_audit_data ad; struct avc_audit_data ad;
err = secondary_ops->netlink_recv(skb, capability); err = cap_netlink_recv(skb, capability);
if (err) if (err)
return err; return err;
......
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