From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=84.16.66.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794910739; b=PzmDZ+jmkDfqY/kIycB6vVocx2cSQOz2A2SmAE3NslloYDUTD/0EK7bycNcUZ2CB3Yog 59wXTgkSBjAI9E0fhnvUlF2jtWPR5mOdStCtLaaX8CgY1FS4lT9bczlGEqcm1y0cuu8D4 mv47vXOIvMY33JG2ZrK7KzrXF5JagrYjLeiPhH2e/XFKzrpF+zOYMlBUDHU/Er6T55ybX FqLqzIa6V1pftZxVyXcR6vD0aZUSgc/yRBy9zlODOIg41+YWOLXvEBKQckdrAYMsdb9K9 mD0pUGYvUO3FefjXevV8cYfEFLK3AlGTyI07EdWJ5ZKJ5UVs6G4sDrNm1GJAjfzdKjQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794910739; h=DMARC-Filter:Received:DKIM-Signature:Received:From:To:Cc:Subject: Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding:X-Infomaniak-Routing; bh=nb6Y3qBz5md8bEdKSYVr1uCQAxRH1CiYfiJZ2O+ozgw=; b=N/ipsOqwidJ5tsySW+HFFnuTm5y+nFVotcprPWuft25Yh2IP+Og+Boco++UY27Q/xent ifDzN1JjUxdMbvPJuJBU0P6y5qrkh+uoSe3+Il9dqip7gSdsOuCeWKKGSEFnqzr8px6oC kMUJdcV/29Jauf9+J5/hyJfUd+g+LX61VzWeLleEQoADTRXplU/z89zUWmXBVl1w8p2I6 sPHtngSOZLYJbe55Ku0ulENrnhuqAa5kxdOxMt/j4ZLFHjI3AM5roIOPSw++MApYZadaH 2De2FmGnuDl4yfwp6wL7AlWurqvI4844dlesvh9HbfJRC+sgEaMdtv0NO/B9s0DgZ6A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass header.d=digikod.net header.i=@digikod.net header.a=rsa-sha256 header.s=20191114 header.b=xaWcp5Pp; arc=none smtp.remote-ip=84.16.66.175 Received: from smtp-42af.mail.infomaniak.ch (smtp-42af.mail.infomaniak.ch [84.16.66.175]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAF65606A899 for ; Tue, 17 Nov 2026 10:18:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CAF65606A899 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.a=rsa-sha256 header.s=20191114 header.b=xaWcp5Pp Received: from smtp-4-0001 (smtp-4-0001.mail.infomaniak.ch [10.7.10.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4jTLL91k7hzWVh; Tue, 17 Nov 2026 11:18:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1794910736; bh=nb6Y3qBz5md8bEdKSYVr1uCQAxRH1CiYfiJZ2O+ozgw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xaWcp5PpJnfMZk8QtNBy5SgREAEo8OKPqQtqrQlAkAfQqJMtqzO3+yDfEhfGcpS/B f55mw+OmjW5Z5/a5LtuAVUb2CREXTnGQk/cu4jpwmXLQjSH5Vys9bVCaq79JFHROjv 1PaV+vYKtkjT2G2k1fP+VlM7QcOW3999ttZQTL9A= Received: from unknown by smtp-4-0001 (Postfix) with ESMTPA id 4jTLL73kJhzV1D; Tue, 17 Nov 2026 11:18:55 +0100 (CET) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Casey Schaufler , Georgia Garcia , =?UTF-8?q?G=C3=BCnther=20Noack?= , James Morris , John Johansen , =?UTF-8?q?Ondrej=20Mosn=C3=A1=C4=8Dek?= , Paul Moore , Serge Hallyn , Stephen Smalley Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Christian Brauner , KP Singh , Matt Bobrowski , apparmor@lists.ubuntu.com, bpf@vger.kernel.org, kernel-team@cloudflare.com, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Subject: [PATCH v2 5/6] selinux: Use security_capable_lsm() for CAP_MAC_ADMIN checks Date: Tue, 17 Nov 2026 11:18:42 +0100 Message-ID: <20261117101845.2523770-6-mic@digikod.net> In-Reply-To: <20261117101845.2523770-1-mic@digikod.net> References: <20261117101845.2523770-1-mic@digikod.net> X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Infomaniak-Routing: alpha has_cap_mac_admin() checks CAP_MAC_ADMIN with cap_capable() and then with SELinux's own check, so that other stacked LSMs do not have to authorize it (see commit db59000ab760 ("selinux: only invoke capabilities and selinux for CAP_MAC_ADMIN checks")). This also lets a process in a Landlock domain that denies CAP_MAC_ADMIN get or set security contexts unknown to the loaded policy. Switch this check to security_capable_lsm(), as for AppArmor and Smack in the previous commits. The cred_has_capability() check is kept. Cc: Günther Noack Cc: Ondrej Mosnáček Cc: Paul Moore Cc: Stephen Smalley Fixes: 97c8386f1d74 ("landlock: Enforce capability restrictions") Signed-off-by: Mickaël Salaün --- security/selinux/hooks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 9950f89dfaa2..5d85bc06f4c5 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3363,7 +3363,8 @@ static bool has_cap_mac_admin(bool audit) const struct cred *cred = current_cred(); unsigned int opts = audit ? CAP_OPT_NONE : CAP_OPT_NOAUDIT; - if (cap_capable(cred, &init_user_ns, CAP_MAC_ADMIN, opts)) + if (security_capable_lsm(cred, &init_user_ns, CAP_MAC_ADMIN, opts, + LSM_ID_SELINUX)) return false; if (cred_has_capability(cred, CAP_MAC_ADMIN, opts, true)) return false; -- 2.56.0