From patchwork Thu May 11 14:25:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 92651 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp4479332rwl; Thu, 11 May 2023 07:29:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ71hB/FuCeuDtbojzI8VPeqr7wBmhQ6AL9KyZ2N1L0aFurl/6CCrBuHw/sqm55ku/e2BJTa X-Received: by 2002:a17:902:ba89:b0:1aa:dba2:d15c with SMTP id k9-20020a170902ba8900b001aadba2d15cmr20165904pls.15.1683815346869; Thu, 11 May 2023 07:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683815346; cv=none; d=google.com; s=arc-20160816; b=sZ05dZ9vYGyNsaeckTbpBxJE44UB7XP5uGavLkh23FPiiqCNwfz6lJ3t1MJMfd3tGw nMaYSE5AkIw4sPUURkb2QD71JT+Mwkcj/2tKmH9J3IAoo2ERgNgLnDttjOzL9HNo5Qt0 D5Y6D+IGJjeRD8BwqCc/HKdx56asedAuDDHrD9X+qyUXZJTODnj0jMivldW9Ip+QU7B/ Kug6v2ZoJzxund27OhACfWX1CAP22NFrqlOnp9C4TFeOTJ3SNdojkD0NEstWgTlZKqGN jrYH7Lk2yY8VgOMEr08WUxOBSLpZB9dAPOLRu6qzEu7lQBnPVgF2kFuchityBKDH4hlS Bo2w== 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 :dkim-signature; bh=NX1eGa2B4zwlKeG6BlsmclZE212qcwapZaeSouPQJvk=; b=ZWANyQICR1pQoeaUsyEuQ9CY8U7Cm2+CSsFrXj47Nw3QXpdTVvgjK1IzBvwBJ3Qqmp XaKYvBDZQRT0Rn2eZ+3cFiGFNPVXd3zq3GRX6KYEmtAw7yRqFttWBKcl5aX1+sXxeRR9 KQ7nif+HiCZxEqNh2+2WfAbS/6andJVzLsYhTZmISG5GOJO/9XyRknRxJp9TnlIOgJxs A+FCe+yn61aNSDWUCxf5gjDRaY22EYJFy0m2D1TKKO9LtVBi3WugpL5qnZihGJewBeLR hi8O/ABCriS+RnESA3Crb41gXV81diPMs/0lictcevub+d2vgbrgNNbpJ5tlvkVAmS8i 3h+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20221208 header.b=eXB5yE1v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170902748b00b001adc3a1b3fasi2034504pll.282.2023.05.11.07.28.53; Thu, 11 May 2023 07:29:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@googlemail.com header.s=20221208 header.b=eXB5yE1v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238533AbjEKO1o (ORCPT + 99 others); Thu, 11 May 2023 10:27:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238443AbjEKO06 (ORCPT ); Thu, 11 May 2023 10:26:58 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29E15106E2; Thu, 11 May 2023 07:26:43 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9659c5b14d8so1430154166b.3; Thu, 11 May 2023 07:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20221208; t=1683815201; x=1686407201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NX1eGa2B4zwlKeG6BlsmclZE212qcwapZaeSouPQJvk=; b=eXB5yE1v2WQ0PSpMfBeBo/WdgEpufMgmK/+iTeF5dgyEMjqGCtqfLLroXENpZ/Nnga 2gftvlN2sPWKeyAUul+z/Y0ktcMv4EXx4DJuQZ4+GY6vFD9ZwnfL0Aw5beQJZUJSrbtP Bn1w65DqCBQGjie3s35YNzURxW5H2DD90Ocfu2YioDvQmPGLozIsqhW/akKi0SnUIfi+ feOJUy4uJXjRqE6TxzYSbMjHOd8mWE9zhZZJ5xHgL5+48m5I4tUIc+1I16/MRAcn2Y+u To/boRZtv3+EcXS/bZv19RvBO59u3dTZTDeuK85XLNe/JwrmkknGA2ypOEZoMBlscFET TMBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683815201; x=1686407201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NX1eGa2B4zwlKeG6BlsmclZE212qcwapZaeSouPQJvk=; b=Uedu4RxLhqELAmG6r//nVcqoyP87eVGb1BbzmIc2fYCneVWSq/qVxpIvB64ioCYDsa KL4ZtTJZLmTrWvVuxuWXusDYfR7QBhpuDbahG1Ql8mnmOjgHndTeCq5h/UbwOhMtZcf1 lAcIPDGJL5Ug3nHLFIEDvTmty12ky2V8831GnnFNC/m4dt1xELXhorzcaniyCVUmR8OD Dadv4oDDpjyQAP38VV6lT46IJU5ajoBkzCyhGSAAIx2XzA+7ycRcQsAPZtcHO9hPntqE Kj8GZic2F+hH0uuX3Ihl3DHxEZy3lgphqMPHewkCMzd5TtraV6VdGc4ukt/TZr9WgtSx +GSA== X-Gm-Message-State: AC+VfDxHh0byo8z9J94RXfRA+4rDHHCyvGS5BE2V5YXmzR55eB/Ib6Xa VouHedFZPHCTZcIHdjYA5Vpmz3nqkQrioQ== X-Received: by 2002:a17:907:26c1:b0:965:eef3:f9b9 with SMTP id bp1-20020a17090726c100b00965eef3f9b9mr18589768ejc.29.1683815201440; Thu, 11 May 2023 07:26:41 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-008-180-228.77.8.pool.telefonica.de. [77.8.180.228]) by smtp.gmail.com with ESMTPSA id hf15-20020a1709072c4f00b0094f58a85bc5sm4056647ejc.180.2023.05.11.07.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 07:26:41 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 8/9] bpf: use new capable_any functionality Date: Thu, 11 May 2023 16:25:31 +0200 Message-Id: <20230511142535.732324-8-cgzones@googlemail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230511142535.732324-1-cgzones@googlemail.com> References: <20230511142535.732324-1-cgzones@googlemail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765608361387733245?= X-GMAIL-MSGID: =?utf-8?q?1765608361387733245?= Use the new added capable_any function in appropriate cases, where a task is required to have any of two capabilities. Signed-off-by: Christian Göttsche Acked-by: Andrii Nakryiko --- v3: rename to capable_any() --- kernel/bpf/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 14f39c1e573e..1bd50da05a22 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -2539,7 +2539,7 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, u32 uattr_size) !bpf_capable()) return -EPERM; - if (is_net_admin_prog_type(type) && !capable(CAP_NET_ADMIN) && !capable(CAP_SYS_ADMIN)) + if (is_net_admin_prog_type(type) && !capable_any(CAP_NET_ADMIN, CAP_SYS_ADMIN)) return -EPERM; if (is_perfmon_prog_type(type) && !perfmon_capable()) return -EPERM;