[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201030123849.770769-3-mic@digikod.net>
Date: Fri, 30 Oct 2020 13:38:49 +0100
From: Mickaël Salaün <mic@...ikod.net>
To: Christian Brauner <christian.brauner@...ntu.com>,
Jann Horn <jannh@...gle.com>,
Kees Cook <keescook@...omium.org>,
Oleg Nesterov <oleg@...hat.com>
Cc: Mickaël Salaün <mic@...ikod.net>,
Eric Paris <eparis@...hat.com>,
James Morris <jmorris@...ei.org>,
"Serge E . Hallyn" <serge@...lyn.com>,
Tyler Hicks <tyhicks@...ux.microsoft.com>,
Will Drewry <wad@...omium.org>, linux-kernel@...r.kernel.org,
stable@...r.kernel.org,
Mickaël Salaün <mic@...ux.microsoft.com>
Subject: [PATCH v1 2/2] seccomp: Set PF_SUPERPRIV when checking capability
From: Mickaël Salaün <mic@...ux.microsoft.com>
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 <jannh@...gle.com>
Cc: Kees Cook <keescook@...omium.org>
Cc: Tyler Hicks <tyhicks@...ux.microsoft.com>
Cc: Will Drewry <wad@...omium.org>
Cc: stable@...r.kernel.org
Fixes: e2cfabdfd075 ("seccomp: add system call filtering using BPF")
Signed-off-by: Mickaël Salaün <mic@...ux.microsoft.com>
---
kernel/seccomp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 8ad7a293255a..53a7d1512dd7 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -38,7 +38,7 @@
#include <linux/filter.h>
#include <linux/pid.h>
#include <linux/ptrace.h>
-#include <linux/security.h>
+#include <linux/capability.h>
#include <linux/tracehook.h>
#include <linux/uaccess.h>
#include <linux/anon_inodes.h>
@@ -558,8 +558,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 */
--
2.28.0
Powered by blists - more mailing lists