From: Mickaël Salaün Date: Fri, 30 Oct 2020 12:38:49 +0000 (+0100) Subject: seccomp: Set PF_SUPERPRIV when checking capability X-Git-Tag: v5.4.80~6 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=09652ebd0dc1a4fd0069410261eea55bd8f6df6c;p=users%2Fdwmw2%2Flinux.git seccomp: Set PF_SUPERPRIV when checking capability commit fb14528e443646dd3fd02df4437fcf5265b66baa upstream. Replace the use of security_capable(current_cred(), ...) with ns_capable_noaudit() which set PF_SUPERPRIV. Since commit 98f368e9e263 ("kernel: Add noaudit variant of ns_capable()"), a new ns_capable_noaudit() helper is available. Let's use it! Cc: Jann Horn Cc: Kees Cook Cc: Tyler Hicks Cc: Will Drewry Cc: stable@vger.kernel.org Fixes: e2cfabdfd075 ("seccomp: add system call filtering using BPF") Signed-off-by: Mickaël Salaün Reviewed-by: Jann Horn Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20201030123849.770769-3-mic@digikod.net Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 0d991e9626f68..4221a4383cfc5 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -453,8 +453,7 @@ static struct seccomp_filter *seccomp_prepare_filter(struct sock_fprog *fprog) * behavior of privileged children. */ if (!task_no_new_privs(current) && - security_capable(current_cred(), current_user_ns(), - CAP_SYS_ADMIN, CAP_OPT_NOAUDIT) != 0) + !ns_capable_noaudit(current_user_ns(), CAP_SYS_ADMIN)) return ERR_PTR(-EACCES); /* Allocate a new seccomp_filter */