Skip to content

Commit 09652eb

Browse files
l0kodgregkh
authored andcommitted
seccomp: Set PF_SUPERPRIV when checking capability
commit fb14528 upstream. Replace the use of security_capable(current_cred(), ...) with ns_capable_noaudit() which set PF_SUPERPRIV. Since commit 98f368e ("kernel: Add noaudit variant of ns_capable()"), a new ns_capable_noaudit() helper is available. Let's use it! Cc: Jann Horn <jannh@google.com> Cc: Kees Cook <keescook@chromium.org> Cc: Tyler Hicks <tyhicks@linux.microsoft.com> Cc: Will Drewry <wad@chromium.org> Cc: stable@vger.kernel.org Fixes: e2cfabd ("seccomp: add system call filtering using BPF") Signed-off-by: Mickaël Salaün <mic@linux.microsoft.com> Reviewed-by: Jann Horn <jannh@google.com> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20201030123849.770769-3-mic@digikod.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fa9ccc1 commit 09652eb

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

kernel/seccomp.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include <linux/filter.h>
3838
#include <linux/pid.h>
3939
#include <linux/ptrace.h>
40-
#include <linux/security.h>
40+
#include <linux/capability.h>
4141
#include <linux/tracehook.h>
4242
#include <linux/uaccess.h>
4343
#include <linux/anon_inodes.h>
@@ -453,8 +453,7 @@ static struct seccomp_filter *seccomp_prepare_filter(struct sock_fprog *fprog)
453453
* behavior of privileged children.
454454
*/
455455
if (!task_no_new_privs(current) &&
456-
security_capable(current_cred(), current_user_ns(),
457-
CAP_SYS_ADMIN, CAP_OPT_NOAUDIT) != 0)
456+
!ns_capable_noaudit(current_user_ns(), CAP_SYS_ADMIN))
458457
return ERR_PTR(-EACCES);
459458

460459
/* Allocate a new seccomp_filter */

0 commit comments

Comments
 (0)