From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A36E2AE8D; Tue, 11 Nov 2025 00:49:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762822172; cv=none; b=UJ95pXnX91q6q+eqJPNck+lM4NCDGkEKJdIfkEP49moGYKvL6bl+cBRFlOtmQ402JCfGQ6oTPa5YXS7D7MC/NWBwSqT2L9ET2V5N30CVBcsGz/VnjDSbAjBAAQRsELAwJCgx8cJHB7lDc7w4QkX7BYpMgKAsmEiarMfsXytBCh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762822172; c=relaxed/simple; bh=2ZeWSSzN3lZe4d4epqYobxgnIAHlzd4Mtn6ll3snAOQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QXLih0xC2cmKDN/YSBOciegJ0D4+UksXC9Lz9lq4j3hIBnyI4R2+X98mK/c9WrUSEcM6O3UJwLLmbqoP4o5g9xOctbz9LZ7v5ghSvqzJXCx8VOfCmM8vExWwOhD8XaUnGiuWIaWSP98hbnvw7r0m2hEQhgeHYsfx5ej+Jk1YgmU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0QEVL2tH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0QEVL2tH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADCFFC4CEF5; Tue, 11 Nov 2025 00:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1762822172; bh=2ZeWSSzN3lZe4d4epqYobxgnIAHlzd4Mtn6ll3snAOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0QEVL2tH6kVom8YD2Da45m3/6M5KmsNB2gAO8ycYUtJTfqUolpS/vMj4bU7vK5buo gU/9K+jyytXoHR3SiY3tWagrtK5bGZBOUFDXmawvmQAk/Avp+ZTR319AeNPDvBW07p UMXexixhHAQ8BaINiTEyuaNjp4etnBqF2iSioWWg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ondrej Mosnacek , Paul Moore , Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.17 046/849] bpf: Do not audit capability check in do_jit() Date: Tue, 11 Nov 2025 09:33:36 +0900 Message-ID: <20251111004537.554496776@linuxfoundation.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251111004536.460310036@linuxfoundation.org> References: <20251111004536.460310036@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ondrej Mosnacek [ Upstream commit 881a9c9cb7856b24e390fad9f59acfd73b98b3b2 ] The failure of this check only results in a security mitigation being applied, slightly affecting performance of the compiled BPF program. It doesn't result in a failed syscall, an thus auditing a failed LSM permission check for it is unwanted. For example with SELinux, it causes a denial to be reported for confined processes running as root, which tends to be flagged as a problem to be fixed in the policy. Yet dontauditing or allowing CAP_SYS_ADMIN to the domain may not be desirable, as it would allow/silence also other checks - either going against the principle of least privilege or making debugging potentially harder. Fix it by changing it from capable() to ns_capable_noaudit(), which instructs the LSMs to not audit the resulting denials. Link: https://bugzilla.redhat.com/show_bug.cgi?id=2369326 Fixes: d4e89d212d40 ("x86/bpf: Call branch history clearing sequence on exit") Signed-off-by: Ondrej Mosnacek Reviewed-by: Paul Moore Link: https://lore.kernel.org/r/20251021122758.2659513-1-omosnace@redhat.com Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- arch/x86/net/bpf_jit_comp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 7e3fca1646203..574586a6d97f8 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -2592,7 +2592,7 @@ st: if (is_imm8(insn->off)) /* Update cleanup_addr */ ctx->cleanup_addr = proglen; if (bpf_prog_was_classic(bpf_prog) && - !capable(CAP_SYS_ADMIN)) { + !ns_capable_noaudit(&init_user_ns, CAP_SYS_ADMIN)) { u8 *ip = image + addrs[i - 1]; if (emit_spectre_bhb_barrier(&prog, ip, bpf_prog)) -- 2.51.0