Skip to content

Commit 2920a84

Browse files
committed
capabilities: remove all _real_ interfaces
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 <eparis@redhat.com> Acked-by: Serge E. Hallyn <serge.hallyn@canonical.com>
1 parent c7eba4a commit 2920a84

3 files changed

Lines changed: 15 additions & 52 deletions

File tree

‎include/linux/security.h‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,10 +1670,6 @@ int security_capable(const struct cred *cred, struct user_namespace *ns,
16701670
int cap);
16711671
int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
16721672
int cap);
1673-
int security_real_capable(struct task_struct *tsk, struct user_namespace *ns,
1674-
int cap);
1675-
int security_real_capable_noaudit(struct task_struct *tsk,
1676-
struct user_namespace *ns, int cap);
16771673
int security_quotactl(int cmds, int type, int id, struct super_block *sb);
16781674
int security_quota_on(struct dentry *dentry);
16791675
int security_syslog(int type);
@@ -1876,27 +1872,6 @@ static inline int security_capable_noaudit(const struct cred *cred,
18761872
return cap_capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
18771873
}
18781874

1879-
static inline int security_real_capable(struct task_struct *tsk, struct user_namespace *ns, int cap)
1880-
{
1881-
int ret;
1882-
1883-
rcu_read_lock();
1884-
ret = cap_capable(__task_cred(tsk), ns, cap, SECURITY_CAP_AUDIT);
1885-
rcu_read_unlock();
1886-
return ret;
1887-
}
1888-
1889-
static inline
1890-
int security_real_capable_noaudit(struct task_struct *tsk, struct user_namespace *ns, int cap)
1891-
{
1892-
int ret;
1893-
1894-
rcu_read_lock();
1895-
ret = cap_capable(__task_cred(tsk), ns, cap, SECURITY_CAP_NOAUDIT);
1896-
rcu_read_unlock();
1897-
return ret;
1898-
}
1899-
19001875
static inline int security_quotactl(int cmds, int type, int id,
19011876
struct super_block *sb)
19021877
{

‎kernel/capability.c‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ SYSCALL_DEFINE2(capset, cap_user_header_t, header, const cap_user_data_t, data)
298298
*/
299299
bool has_capability(struct task_struct *t, int cap)
300300
{
301-
int ret = security_real_capable(t, &init_user_ns, cap);
301+
int ret;
302+
303+
rcu_read_lock();
304+
ret = security_capable(__task_cred(t), &init_user_ns, cap);
305+
rcu_read_unlock();
302306

303307
return (ret == 0);
304308
}
@@ -317,7 +321,11 @@ bool has_capability(struct task_struct *t, int cap)
317321
bool has_ns_capability(struct task_struct *t,
318322
struct user_namespace *ns, int cap)
319323
{
320-
int ret = security_real_capable(t, ns, cap);
324+
int ret;
325+
326+
rcu_read_lock();
327+
ret = security_capable(__task_cred(t), ns, cap);
328+
rcu_read_unlock();
321329

322330
return (ret == 0);
323331
}
@@ -335,7 +343,11 @@ bool has_ns_capability(struct task_struct *t,
335343
*/
336344
bool has_capability_noaudit(struct task_struct *t, int cap)
337345
{
338-
int ret = security_real_capable_noaudit(t, &init_user_ns, cap);
346+
int ret;
347+
348+
rcu_read_lock();
349+
ret = security_capable_noaudit(__task_cred(t), &init_user_ns, cap);
350+
rcu_read_unlock();
339351

340352
return (ret == 0);
341353
}

‎security/security.c‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -166,30 +166,6 @@ int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
166166
return security_ops->capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
167167
}
168168

169-
int security_real_capable(struct task_struct *tsk, struct user_namespace *ns,
170-
int cap)
171-
{
172-
const struct cred *cred;
173-
int ret;
174-
175-
cred = get_task_cred(tsk);
176-
ret = security_ops->capable(cred, ns, cap, SECURITY_CAP_AUDIT);
177-
put_cred(cred);
178-
return ret;
179-
}
180-
181-
int security_real_capable_noaudit(struct task_struct *tsk,
182-
struct user_namespace *ns, int cap)
183-
{
184-
const struct cred *cred;
185-
int ret;
186-
187-
cred = get_task_cred(tsk);
188-
ret = security_ops->capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
189-
put_cred(cred);
190-
return ret;
191-
}
192-
193169
int security_quotactl(int cmds, int type, int id, struct super_block *sb)
194170
{
195171
return security_ops->quotactl(cmds, type, id, sb);

0 commit comments

Comments
 (0)