From: sashiko-bot@kernel.org
To: "Pawan Gupta" <pawan.kumar.gupta@linux.intel.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 7.1.y 2/6] x86/bugs: Enable IBPB flush on BPF JIT allocation
Date: Thu, 09 Jul 2026 22:37:15 +0000 [thread overview]
Message-ID: <20260709223715.93C851F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260709-cbpf-jit-spray-hardening-7-1-y-v1-2-5ac5a2d6797f@linux.intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incomplete Spectre v2 / BHI mitigation for BPF JIT spraying on CPUs with RRSBA.
- [High] Unprivileged local Denial of Service (DoS) via synchronous IPI broadcast storm.
--
--- Patch [2]: [PATCH 7.1.y 2/6] x86/bugs: Enable IBPB flush on BPF JIT allocation ---
commit 9b68eba3d351f7dea03fa0a56d5f7eb7c06e801c
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
x86/bugs: Enable IBPB flush on BPF JIT allocation
Enable hardening against JIT spraying when Spectre-v2 mitigations are in
use. Specifically, issue an IBPB flush on BPF JIT memory reuse. Skip
enabling the IBPB flush if the BPF dispatcher is already using a retpoline
sequence.
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> index 83f51cab0b1e3..d9af230c05125 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
[ ... ]
> @@ -2238,6 +2251,27 @@ static void __init spectre_v2_update_mitigation(void)
> pr_info("%s\n", spectre_v2_strings[spectre_v2_enabled]);
> }
>
> +#ifdef CONFIG_BPF_JIT
> +static void __bpf_arch_ibpb(void *unused)
> +{
> + write_ibpb();
> +}
> +
> +void bpf_arch_ibpb(void)
> +{
> + on_each_cpu(__bpf_arch_ibpb, NULL, 1);
> +}
[Severity: High]
Does this expose the system to a Denial of Service (DoS) attack from
unprivileged users?
Since this static call is invoked during BPF JIT allocations (e.g. via
bpf_arch_pred_flush() in bpf_prog_pack_alloc()), an unprivileged user can
repeatedly attach and detach classic BPF socket filters using
setsockopt(SO_ATTACH_FILTER).
This would trigger on_each_cpu(..., 1) repeatedly, overwhelming all online
CPUs with a synchronous IPI broadcast and waiting for them to complete the
expensive write_ibpb() operation.
> +
> +static bool __init cpu_wants_ibpb_bpf(void)
> +{
> + /* A genuine retpoline already neutralizes ring0 indirect predictions */
> + if (retpoline_seq_enabled())
> + return false;
[Severity: High]
Is it safe to assume retpolines are a complete mitigation here without also
verifying that RRSBA is safely disabled?
In other mitigation paths like bhi_apply_mitigation() and spectre_bhi_state(),
the kernel checks rrsba_disabled along with retpoline_seq_enabled() because
an RSB underflow on CPUs with Restricted Return Stack Buffer Alternate (RRSBA)
behavior can cause RET instructions to fall back to the BTB (which could be
poisoned by an attacker).
If a system has RRSBA that cannot be disabled, skipping the IBPB flush here
could leave the BPF JIT spraying mitigation incomplete.
> +
> + return boot_cpu_has(X86_FEATURE_IBPB);
> +}
> +#endif
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-cbpf-jit-spray-hardening-7-1-y-v1-0-5ac5a2d6797f@linux.intel.com?part=2
next prev parent reply other threads:[~2026-07-09 22:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 22:22 [PATCH 7.1.y 0/6] cBPF JIT spray hardening Pawan Gupta
2026-07-09 22:23 ` [PATCH 7.1.y 1/6] bpf: Support for hardening against JIT spraying Pawan Gupta
2026-07-09 22:37 ` sashiko-bot
2026-07-09 22:52 ` bot+bpf-ci
2026-07-09 22:23 ` [PATCH 7.1.y 2/6] x86/bugs: Enable IBPB flush on BPF JIT allocation Pawan Gupta
2026-07-09 22:37 ` sashiko-bot [this message]
2026-07-09 22:23 ` [PATCH 7.1.y 3/6] bpf: Restrict JIT predictor flush to cBPF Pawan Gupta
2026-07-09 22:35 ` sashiko-bot
2026-07-09 22:23 ` [PATCH 7.1.y 4/6] bpf: Skip redundant IBPB in pack allocator Pawan Gupta
2026-07-09 22:24 ` [PATCH 7.1.y 5/6] bpf: Prefer packs that won't trigger an IBPB flush on allocation Pawan Gupta
2026-07-09 22:24 ` [PATCH 7.1.y 6/6] bpf: Prefer dirty packs for eBPF allocations Pawan Gupta
2026-07-10 21:03 ` [PATCH 7.1.y 0/6] cBPF JIT spray hardening Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260709223715.93C851F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox