diff options
author | James Morse <james.morse@arm.com> | 2025-04-29 16:03:38 +0100 |
---|---|---|
committer | James Morse <james.morse@arm.com> | 2025-05-08 15:29:03 +0100 |
commit | f300769ead032513a68e4a02e806393402e626f8 (patch) | |
tree | ab218adf54026c926d3549008b8bf3404bb6d708 | |
parent | 0dfefc2ea2f29ced2416017d7e5b1253a54c2735 (diff) |
arm64: bpf: Only mitigate cBPF programs loaded by unprivileged users
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>
-rw-r--r-- | arch/arm64/net/bpf_jit_comp.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 0ab8e47062d9..634d78422adb 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -952,6 +952,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; |