seccomp: Set PF_SUPERPRIV when checking capability
commitfb14528e44upstream. Replace the use of security_capable(current_cred(), ...) with ns_capable_noaudit() which set PF_SUPERPRIV. Since commit98f368e9e2("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:e2cfabdfd0("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
fa9ccc1777
commit
09652ebd0d
@@ -37,7 +37,7 @@
|
|||||||
#include <linux/filter.h>
|
#include <linux/filter.h>
|
||||||
#include <linux/pid.h>
|
#include <linux/pid.h>
|
||||||
#include <linux/ptrace.h>
|
#include <linux/ptrace.h>
|
||||||
#include <linux/security.h>
|
#include <linux/capability.h>
|
||||||
#include <linux/tracehook.h>
|
#include <linux/tracehook.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/anon_inodes.h>
|
#include <linux/anon_inodes.h>
|
||||||
@@ -453,8 +453,7 @@ static struct seccomp_filter *seccomp_prepare_filter(struct sock_fprog *fprog)
|
|||||||
* behavior of privileged children.
|
* behavior of privileged children.
|
||||||
*/
|
*/
|
||||||
if (!task_no_new_privs(current) &&
|
if (!task_no_new_privs(current) &&
|
||||||
security_capable(current_cred(), current_user_ns(),
|
!ns_capable_noaudit(current_user_ns(), CAP_SYS_ADMIN))
|
||||||
CAP_SYS_ADMIN, CAP_OPT_NOAUDIT) != 0)
|
|
||||||
return ERR_PTR(-EACCES);
|
return ERR_PTR(-EACCES);
|
||||||
|
|
||||||
/* Allocate a new seccomp_filter */
|
/* Allocate a new seccomp_filter */
|
||||||
|
|||||||
Reference in New Issue
Block a user