Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3398112lkq; Mon, 23 Nov 2020 04:49:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyr1syuJOIxZkP0Ziyr2xyvHh7INIoGMaYCvvPZeZkMvGC2RjNHa35vwLszOblJtpbP+B43 X-Received: by 2002:a17:906:b143:: with SMTP id bt3mr23118468ejb.318.1606135752876; Mon, 23 Nov 2020 04:49:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606135752; cv=none; d=google.com; s=arc-20160816; b=xo5WfeM+vD1twE76/istUnpeUMnO3aslt64XF6xzdF5frxc5j289bRQ1eAtm0s2mre vZ47DaX3NcX1oWoIu6TzMf9nT0WTQq2AItkVP5NUNZhaW/Cvgy/o0OzRLPh7UTsuD+H5 EkM6MtVxokEQdBRJzk5VNW4Gd5KLpAyVc45N4rxddGkVI3REMny3HGzjrjuaExw+sV9g yJm87fYgNKxdFmv7jv3wkgAmIv6icQH1ibVIC+9QY6bfsAEGqSrujQSdYiY+C8usHbXp acKvDGGcIacAkm641W97GwvR7jdg01aZqQWRM3mNYRz/kpuxdYTh4vognwVV3wQqO5tz qIhw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2CnU6af9iKeD29eq15gW3TZnLpuf8Ab0aLO4IiiXOqA=; b=u5/Kv1bRVGBW9qimjy8LBg4tH8nj4sFM1mrixga6zbv3WyzvJ4UD0tFIz7Xh2JHc/O ZtZStw/HvO00SV6mnK7jBbOPi3zjQ9St7MDh6OG05aVBjzxy6MECiD9MrsgP6KY4x2Q+ uzZS85dWpHpA3kOUVgznSqUpNBtdg7uJ4LtrCxwGpeqsnQ8473c+ck0NNLgVekXcvE8v HPU/BbGywJHtbevoFdpTHt25a127SES1+nqi3BLAr3B9iavYu0J3TN/EvFzYBUPfouEg m5AkKLbJ7DM60Mv+afQ6o2dn4KurKY3uAiLO9Jnn8ov4Kx8hENv8Joi3JAiKRqFGHBuj ghFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nl5mDVR6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si6301732ejp.532.2020.11.23.04.48.50; Mon, 23 Nov 2020 04:49:12 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nl5mDVR6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733008AbgKWMnA (ORCPT + 99 others); Mon, 23 Nov 2020 07:43:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:53666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732556AbgKWMkx (ORCPT ); Mon, 23 Nov 2020 07:40:53 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C91D2076E; Mon, 23 Nov 2020 12:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135252; bh=64H2hiQ4enESAv9cU4VMaEvAEFea5P3rJu/9zIILp+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nl5mDVR6ZxhFSNzrD+obsWDWP0a44Ermzjj6kuqDrs8cRZRxFU8WwbDsmzEgCghsH pSiniE23jadB42yDcAZLebqNaQ4K+YYEBTpGgpx0IsyLMvfVgG47UTJ9MWg1I16dce ncxwpUY3gFtgNPmXG8pkpMi6UpJBZc7fU5aa94iA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jann Horn , Kees Cook , Tyler Hicks , Will Drewry , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= Subject: [PATCH 5.4 153/158] seccomp: Set PF_SUPERPRIV when checking capability Date: Mon, 23 Nov 2020 13:23:01 +0100 Message-Id: <20201123121827.314118849@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 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 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 --- kernel/seccomp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- 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_pr * 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 */