All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pawan Gupta" <pawan.kumar.gupta@linux.intel.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 6.1.y 3/6] bpf: Restrict JIT predictor flush to cBPF
Date: Mon, 27 Jul 2026 23:06:53 +0000	[thread overview]
Message-ID: <20260727230653.8D98C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727-cbpf-jit-spray-hardening-6-1-y-v1-3-eb80dcf1eb6e@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Spectre v2 Mitigation Bypass for Unprivileged Native eBPF
--

--- Patch [3]: [PATCH 6.1.y 3/6] bpf: Restrict JIT predictor flush to cBPF ---
commit 77faa1df216dd9c68cbac9a596c9d2f4b8b6ffef
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>

bpf: Restrict JIT predictor flush to cBPF

This patch restricts the predictor flush on memory reuse to cBPF programs
only, aiming to reduce performance overhead on busy systems. It skips the
flush for native eBPF allocations under the assumption that eBPF is
privileged.

> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> index 4643554c6e3a9..f78ee18bab3b5 100644
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
[ ... ]
> @@ -947,7 +947,9 @@ void *bpf_prog_pack_alloc(u32 size, bpf_jit_fill_hole_t bpf_fill_ill_insns)
>  	pos = 0;
>  
>  found_free_area:
> -	static_call_cond(bpf_arch_pred_flush)();
> +	/* Flush only for cBPF as it may contain a crafted gadget */
> +	if (static_branch_unlikely(&bpf_pred_flush_enabled) && was_classic)
> +		static_call_cond(bpf_arch_pred_flush)();

[Severity: High]
Does skipping the predictor flush here for native eBPF bypass the Spectre v2
JIT mitigation for unprivileged users?

The commit message notes that eBPF is privileged by default, but unprivileged
local users can still load native eBPF programs (such as
BPF_PROG_TYPE_SOCKET_FILTER) on systems where kernel.unprivileged_bpf_disabled
is set to 0.

Since native eBPF sets was_classic to false, wouldn't bpf_prog_pack_alloc()
now skip the flush and leave unprivileged native eBPF programs unprotected
against branch target poisoning?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260727-cbpf-jit-spray-hardening-6-1-y-v1-0-eb80dcf1eb6e@linux.intel.com?part=3

  reply	other threads:[~2026-07-27 23:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 22:55 [PATCH 6.1.y 0/6] cBPF JIT spray hardening Pawan Gupta
2026-07-27 22:55 ` [PATCH 6.1.y 1/6] bpf: Support for hardening against JIT spraying Pawan Gupta
2026-07-27 23:06   ` sashiko-bot
2026-07-27 22:55 ` [PATCH 6.1.y 2/6] x86/bugs: Enable IBPB flush on BPF JIT allocation Pawan Gupta
2026-07-27 22:56 ` [PATCH 6.1.y 3/6] bpf: Restrict JIT predictor flush to cBPF Pawan Gupta
2026-07-27 23:06   ` sashiko-bot [this message]
2026-07-27 22:56 ` [PATCH 6.1.y 4/6] bpf: Skip redundant IBPB in pack allocator Pawan Gupta
2026-07-27 22:56 ` [PATCH 6.1.y 5/6] bpf: Prefer packs that won't trigger an IBPB flush on allocation Pawan Gupta
2026-07-27 22:56 ` [PATCH 6.1.y 6/6] bpf: Prefer dirty packs for eBPF allocations Pawan Gupta

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=20260727230653.8D98C1F000E9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.