Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1239768pxx; Fri, 30 Oct 2020 05:43:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwV7zpK9wMmo5iE03YWTvFEMBV8rwJtd73n6EOVuMYDb0a0UM5eylEfHL7IKP8sDurrTP6o X-Received: by 2002:a50:f749:: with SMTP id j9mr2050729edn.376.1604061780452; Fri, 30 Oct 2020 05:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604061780; cv=none; d=google.com; s=arc-20160816; b=E5xS9dv0erxbnsOyvQD3Q+cDXWSKJ6ARJxETxwR6T/y0Iu9INqHmTj8HWsXQziIJhL 3g5gE9sJ7HBHsA6sFXvILTeaPmfKvDGhqFB/G8EHEJw3WNT8BirH2/FImBnnQa97Khp/ HFhupL498zyKP663TZocWJVq/19sJnOkS11IOP+bkIlyJ20TjFS4sqxroXFHCp56ksb8 V8f0TTx6AkKyVRCT9tsX/yVfgJcLWbfkzcJaQHJ4b0gtPSzONESEAAe0rxfTmqnWEKt9 +Lfgqzf+1RxQKptk8vNatX5AjZYDH9kckTY9aDBzPor6qOTyfbbHUD2tUmhrHHzeHbIF LvmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CFgd2fGY1ERQynYR9VsgoOh7Z9Z1FgDJU03/Vd10vOc=; b=PTRTWOiprh/XSA7mA5SvCltopa3rgWm/Oav3gg/iXge6Y8eDUpCAN0IbivYmIAa3ys K13NZEH/FdVolFpRvx/W+wvJ0WgziZH66mjhnuRtdR+m55ERCL854RNETqBcrRAYncQb IwuF4QooueDFFvY/imkBh3ABM9zQRlUcIQCU5uN8LiniB0s/m4i8Jk1xdhjZbBoa9Vox sp9tCa+2ma77ydk7rZzrsvQkewosv4djbm0O8juynuEbAysbQnqq0EG+TqOgdzPW6HKZ U6JqMLXcXlWRv5dQp6ssgUH7v3Oy/PZ03o3nOcIBtuFYkX1GdQNe8fS9P7cxsU1perZr gUVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si3286713edn.68.2020.10.30.05.42.37; Fri, 30 Oct 2020 05:43:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726545AbgJ3MjB (ORCPT + 99 others); Fri, 30 Oct 2020 08:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726224AbgJ3MjA (ORCPT ); Fri, 30 Oct 2020 08:39:00 -0400 Received: from smtp-bc09.mail.infomaniak.ch (smtp-bc09.mail.infomaniak.ch [IPv6:2001:1600:3:17::bc09]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C534C0613D4 for ; Fri, 30 Oct 2020 05:39:00 -0700 (PDT) Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4CN21G6tpXzlhjYs; Fri, 30 Oct 2020 13:38:58 +0100 (CET) Received: from localhost (unknown [94.23.54.103]) by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4CN21G5BxVzlh8TD; Fri, 30 Oct 2020 13:38:58 +0100 (CET) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Jann Horn , Kees Cook , Oleg Nesterov Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Eric Paris , James Morris , "Serge E . Hallyn" , Tyler Hicks , Will Drewry , linux-kernel@vger.kernel.org, stable@vger.kernel.org, =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= Subject: [PATCH v1 2/2] seccomp: Set PF_SUPERPRIV when checking capability Date: Fri, 30 Oct 2020 13:38:49 +0100 Message-Id: <20201030123849.770769-3-mic@digikod.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201030123849.770769-1-mic@digikod.net> References: <20201030123849.770769-1-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mickaël Salaün 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 --- 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 #include #include -#include +#include #include #include #include @@ -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