Skip to content

Commit c7eba4a

Browse files
committed
capabilities: introduce security_capable_noaudit
Exactly like security_capable except don't audit any denials. This is for places where the kernel may make decisions about what to do if a task has a given capability, but which failing that capability is not a sign of a security policy violation. An example is checking if a task has CAP_SYS_ADMIN to lower it's likelyhood of being killed by the oom killer. This check is not a security violation if it is denied. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Serge E. Hallyn <serge.hallyn@canonical.com>
1 parent b7e724d commit c7eba4a

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎include/linux/security.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,8 @@ int security_capset(struct cred *new, const struct cred *old,
16681668
const kernel_cap_t *permitted);
16691669
int security_capable(const struct cred *cred, struct user_namespace *ns,
16701670
int cap);
1671+
int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
1672+
int cap);
16711673
int security_real_capable(struct task_struct *tsk, struct user_namespace *ns,
16721674
int cap);
16731675
int security_real_capable_noaudit(struct task_struct *tsk,
@@ -1869,6 +1871,11 @@ static inline int security_capable(const struct cred *cred,
18691871
return cap_capable(cred, ns, cap, SECURITY_CAP_AUDIT);
18701872
}
18711873

1874+
static inline int security_capable_noaudit(const struct cred *cred,
1875+
struct user_namespace *ns, int cap) {
1876+
return cap_capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
1877+
}
1878+
18721879
static inline int security_real_capable(struct task_struct *tsk, struct user_namespace *ns, int cap)
18731880
{
18741881
int ret;

‎security/security.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ int security_capable(const struct cred *cred, struct user_namespace *ns,
160160
return security_ops->capable(cred, ns, cap, SECURITY_CAP_AUDIT);
161161
}
162162

163+
int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
164+
int cap)
165+
{
166+
return security_ops->capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
167+
}
168+
163169
int security_real_capable(struct task_struct *tsk, struct user_namespace *ns,
164170
int cap)
165171
{

0 commit comments

Comments
 (0)