From patchwork Thu May 11 14:25:30 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: 13238035 X-Patchwork-Delegate: paul@paul-moore.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9751C7EE26 for ; Thu, 11 May 2023 14:27:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238520AbjEKO1b (ORCPT ); Thu, 11 May 2023 10:27:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238389AbjEKO06 (ORCPT ); Thu, 11 May 2023 10:26:58 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09A1711568; Thu, 11 May 2023 07:26:41 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-50bd2d7ba74so79896065a12.1; Thu, 11 May 2023 07:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20221208; t=1683815200; x=1686407200; 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=omcL1tQTkN45wCKai+1Kbbd8238ac0Z+pI3Znyzufew=; b=rKqibNf1l2a12KI79rqt5KPK4zm1S3BNWMM35Ahix1Jc8c38zD5DWVJbqB66b+JtD3 HDU694w3CQsEfsLkGWy0XOzhc04GoQn67u1tAxOkUHBAHSyWwR2C0rvfTjwL9x6lzlLs 6Gma1AQHwBXhb9DLBkBYQivjRJN3QLF93mnwRSqrsxW7RtI0Tzqn0cYU2e/IlQacAzSQ THkQ3suYfAAtNs7YgMY3bW0jn9CjozSNmVMRZTbSompRGyVpVRWzGgDRvDMwQt/743i/ Sl2JgX/H2nT3b/MUg4lk+1Pb5Q7m7krVG5qak/G1XHT47hcHnmrbGGUnc5Lus57t72sL 6KUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683815200; x=1686407200; 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=omcL1tQTkN45wCKai+1Kbbd8238ac0Z+pI3Znyzufew=; b=hpRoIZRMIPq8Awpp7AUQuW9wovA3V9TcS48ycEk9k0OPyrHV7XhkUkunQu5nJEbJjy Kcme4BMHJuD07XDHPLidTP06SBxWuCDm3UncRo24mhySO/IOrN7mLMI4UX1EzQ3Bk00z Kl/BGCf1n3HL/Fgii6RrKoJ9/4UV90xDiSW7H7guHOdN45ZYLL3W+ost1t0x60V3iBck VUdZunxQo8RqEXEUUgW3Hu7oZLRokaHboiVkgsZDgIDYX01KV9m9FRgFwwEkmKGAqlkB lEDqA9U6C2yfvoPuqS3vG5UX+MOnZ+PJstNmW9QLZZXxvLkxRA75Zjj9335hMr9O7ud/ wM4g== X-Gm-Message-State: AC+VfDzt7iHoeac/KnCF1s+y8IuAzfrpd4HUKKkD/9QEzf/Vfo3RAE27 goam3nqTyM0u6otbzOHT58juKFO5IsVl8w== X-Google-Smtp-Source: ACHHUZ47ZDUYzcnnTlMiXileQs6XajtPBEqjImbXXS/KqNT8pstu7ycYLXSHsE2eSNz9da5Qb+aZiQ== X-Received: by 2002:a17:907:1690:b0:94f:6316:ce8d with SMTP id hc16-20020a170907169000b0094f6316ce8dmr21600343ejc.34.1683815200236; Thu, 11 May 2023 07:26:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 07:26:39 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Cc: Andrew Morton , Christian Brauner , Suren Baghdasaryan , "Liam R. Howlett" , "Michael S. Tsirkin" , Mike Christie , Mathieu Desnoyers , Andrei Vagin , Nicholas Piggin , Peter Zijlstra , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v4 7/9] kernel: use new capable_any functionality Date: Thu, 11 May 2023 16:25:30 +0200 Message-Id: <20230511142535.732324-7-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 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org 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 Reviewed-by: Christian Brauner --- v3: rename to capable_any() --- kernel/fork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/fork.c b/kernel/fork.c index ed4e01daccaa..6e00933e8ef4 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2371,7 +2371,7 @@ __latent_entropy struct task_struct *copy_process( retval = -EAGAIN; if (is_rlimit_overlimit(task_ucounts(p), UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC))) { if (p->real_cred->user != INIT_USER && - !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) + !capable_any(CAP_SYS_RESOURCE, CAP_SYS_ADMIN)) goto bad_fork_cleanup_count; } current->flags &= ~PF_NPROC_EXCEEDED;