]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arm64: bpf: Only mitigate cBPF programs loaded by unprivileged users
authorJames Morse <james.morse@arm.com>
Sat, 7 Jun 2025 15:25:20 +0000 (15:25 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:04:23 +0000 (11:04 +0100)
[ Upstream commit f300769ead032513a68e4a02e806393402e626f8 ]

Support for eBPF programs loaded by unprivileged users is typically
disabled. This means only cBPF programs need to be mitigated for BHB.

In addition, only mitigate cBPF programs that were loaded by an
unprivileged user. Privileged users can also load the same program
via eBPF, making the mitigation pointless.

Signed-off-by: James Morse <james.morse@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/net/bpf_jit_comp.c

index 5c3f82c168a2774c36d6fa411d5c110204585b25..970d8f318177c32c8eb233771be8fdb725e22a6d 100644 (file)
@@ -342,6 +342,9 @@ static void __maybe_unused build_bhb_mitigation(struct jit_ctx *ctx)
            arm64_get_spectre_v2_state() == SPECTRE_VULNERABLE)
                return;
 
+       if (capable(CAP_SYS_ADMIN))
+               return;
+
        if (supports_clearbhb(SCOPE_SYSTEM)) {
                emit(aarch64_insn_gen_hint(AARCH64_INSN_HINT_CLEARBHB), ctx);
                return;