Skip to content

Commit 1ca34df

Browse files
committed
bpf: Do not audit capability check in do_jit()
JIRA: https://issues.redhat.com/browse/RHEL-108805 Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git commit 881a9c9 Author: Ondrej Mosnacek <omosnace@redhat.com> Date: Tue Oct 21 14:27:58 2025 +0200 bpf: Do not audit capability check in do_jit() 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: d4e89d2 ("x86/bpf: Call branch history clearing sequence on exit") Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Reviewed-by: Paul Moore <paul@paul-moore.com> Link: https://lore.kernel.org/r/20251021122758.2659513-1-omosnace@redhat.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
1 parent 2429d88 commit 1ca34df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/net/bpf_jit_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2584,7 +2584,7 @@ st: if (is_imm8(insn->off))
25842584
/* Update cleanup_addr */
25852585
ctx->cleanup_addr = proglen;
25862586
if (bpf_prog_was_classic(bpf_prog) &&
2587-
!capable(CAP_SYS_ADMIN)) {
2587+
!ns_capable_noaudit(&init_user_ns, CAP_SYS_ADMIN)) {
25882588
u8 *ip = image + addrs[i - 1];
25892589

25902590
if (emit_spectre_bhb_barrier(&prog, ip, bpf_prog))

0 commit comments

Comments
 (0)