Skip to content

Commit

Permalink
capabilities: remove all _real_ interfaces
Browse files Browse the repository at this point in the history
The name security_real_capable and security_real_capable_noaudit just don't
make much sense to me.  Convert them to use security_capable and
security_capable_noaudit.

Signed-off-by: Eric Paris <[email protected]>
Acked-by: Serge E. Hallyn <[email protected]>
  • Loading branch information
eparis committed Jan 5, 2012
1 parent c7eba4a commit 2920a84
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 52 deletions.
25 changes: 0 additions & 25 deletions include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -1670,10 +1670,6 @@ int security_capable(const struct cred *cred, struct user_namespace *ns,
int cap);
int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
int cap);
int security_real_capable(struct task_struct *tsk, struct user_namespace *ns,
int cap);
int security_real_capable_noaudit(struct task_struct *tsk,
struct user_namespace *ns, int cap);
int security_quotactl(int cmds, int type, int id, struct super_block *sb);
int security_quota_on(struct dentry *dentry);
int security_syslog(int type);
Expand Down Expand Up @@ -1876,27 +1872,6 @@ static inline int security_capable_noaudit(const struct cred *cred,
return cap_capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
}

static inline int security_real_capable(struct task_struct *tsk, struct user_namespace *ns, int cap)
{
int ret;

rcu_read_lock();
ret = cap_capable(__task_cred(tsk), ns, cap, SECURITY_CAP_AUDIT);
rcu_read_unlock();
return ret;
}

static inline
int security_real_capable_noaudit(struct task_struct *tsk, struct user_namespace *ns, int cap)
{
int ret;

rcu_read_lock();
ret = cap_capable(__task_cred(tsk), ns, cap, SECURITY_CAP_NOAUDIT);
rcu_read_unlock();
return ret;
}

static inline int security_quotactl(int cmds, int type, int id,
struct super_block *sb)
{
Expand Down
18 changes: 15 additions & 3 deletions kernel/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,11 @@ SYSCALL_DEFINE2(capset, cap_user_header_t, header, const cap_user_data_t, data)
*/
bool has_capability(struct task_struct *t, int cap)
{
int ret = security_real_capable(t, &init_user_ns, cap);
int ret;

rcu_read_lock();
ret = security_capable(__task_cred(t), &init_user_ns, cap);
rcu_read_unlock();

return (ret == 0);
}
Expand All @@ -317,7 +321,11 @@ bool has_capability(struct task_struct *t, int cap)
bool has_ns_capability(struct task_struct *t,
struct user_namespace *ns, int cap)
{
int ret = security_real_capable(t, ns, cap);
int ret;

rcu_read_lock();
ret = security_capable(__task_cred(t), ns, cap);
rcu_read_unlock();

return (ret == 0);
}
Expand All @@ -335,7 +343,11 @@ bool has_ns_capability(struct task_struct *t,
*/
bool has_capability_noaudit(struct task_struct *t, int cap)
{
int ret = security_real_capable_noaudit(t, &init_user_ns, cap);
int ret;

rcu_read_lock();
ret = security_capable_noaudit(__task_cred(t), &init_user_ns, cap);
rcu_read_unlock();

return (ret == 0);
}
Expand Down
24 changes: 0 additions & 24 deletions security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,30 +166,6 @@ int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
return security_ops->capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
}

int security_real_capable(struct task_struct *tsk, struct user_namespace *ns,
int cap)
{
const struct cred *cred;
int ret;

cred = get_task_cred(tsk);
ret = security_ops->capable(cred, ns, cap, SECURITY_CAP_AUDIT);
put_cred(cred);
return ret;
}

int security_real_capable_noaudit(struct task_struct *tsk,
struct user_namespace *ns, int cap)
{
const struct cred *cred;
int ret;

cred = get_task_cred(tsk);
ret = security_ops->capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
put_cred(cred);
return ret;
}

int security_quotactl(int cmds, int type, int id, struct super_block *sb)
{
return security_ops->quotactl(cmds, type, id, sb);
Expand Down

0 comments on commit 2920a84

Please sign in to comment.