BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexis Lothoré (eBPF Foundation)" <alexis.lothore@bootlin.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 02/10] bpf: mark instructions accessing program stack
Date: Wed, 08 Jul 2026 08:10:07 +0000	[thread overview]
Message-ID: <20260708081008.402A51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708-kasan-v4-2-d5c177ab8227@bootlin.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] In `adjust_insn_aux_data()`, when replacing an instruction with a single new instruction (`cnt == 1`), `data[off].non_stack_access` is incorrectly set by evaluating `is_mem_insn(insn)` instead of `is_mem_insn(insn + off)`.
--

--- Patch [2]: [PATCH bpf-next v4 02/10] bpf: mark instructions accessing program stack ---
commit 764c11844e954d2fc0370d170803b0deb684733a
Author: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>

bpf: mark instructions accessing program stack

This commit introduces tracking of instructions that access non-stack memory
to help JIT compilers emit KASAN checks. It adds logic to mark BPF
instructions as stack-only by default and overrides this if any state
indicates non-stack access, including adjustments during verifier patching.

> diff --git a/kernel/bpf/fixups.c b/kernel/bpf/fixups.c
> index f515fc9669ce2..feee1f33de9d5 100644
> --- a/kernel/bpf/fixups.c
> +++ b/kernel/bpf/fixups.c

[ ... ]

> @@ -172,8 +184,14 @@ static void adjust_insn_aux_data(struct bpf_verifier_env *env,
>  	 */
>  	data[off].zext_dst = insn_has_def32(insn + off + cnt - 1);
>  
> -	if (cnt == 1)
> +	if (cnt == 1) {
> +		/* A non-memory accessing insn could have been replaced by a
> +		 * memory accessing insn, systematically mark it for non-stack
> +		 * access
> +		 */
> +		data[off].non_stack_access = is_mem_insn(insn);

[Severity: High]
Should this check be using is_mem_insn(insn + off) instead of
is_mem_insn(insn)?

Since insn points to the start of the program (new_prog->insnsi), calling
is_mem_insn(insn) evaluates the very first instruction of the program rather
than the newly patched instruction at the targeted offset.

If the first instruction happens to not be a memory access, will this
incorrectly mark the patched instruction as not accessing non-stack memory
and cause us to miss KASAN instrumentation?

>  		return;
> +	}
>  	prog_len = new_prog->len;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708-kasan-v4-0-d5c177ab8227@bootlin.com?part=2

  reply	other threads:[~2026-07-08  8:10 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08  8:00 [PATCH bpf-next v4 00/10] bpf: add support for KASAN checks in JITed programs Alexis Lothoré (eBPF Foundation)
2026-07-08  8:00 ` [PATCH bpf-next v4 01/10] bpf: propagate original instruction offset when patching program Alexis Lothoré (eBPF Foundation)
2026-07-08  8:19   ` sashiko-bot
2026-07-08 14:11     ` Alexis Lothoré
2026-07-08  8:00 ` [PATCH bpf-next v4 02/10] bpf: mark instructions accessing program stack Alexis Lothoré (eBPF Foundation)
2026-07-08  8:10   ` sashiko-bot [this message]
2026-07-08 14:15     ` Alexis Lothoré
2026-07-08  8:00 ` [PATCH bpf-next v4 03/10] bpf: add BPF_JIT_KASAN for KASAN instrumentation of JITed programs Alexis Lothoré (eBPF Foundation)
2026-07-08 12:48   ` Andrey Konovalov
2026-07-08  8:00 ` [PATCH bpf-next v4 04/10] bpf, x86: add helper to emit kasan checks in x86 " Alexis Lothoré (eBPF Foundation)
2026-07-08  8:16   ` sashiko-bot
2026-07-08 14:20     ` Alexis Lothoré
2026-07-08  8:00 ` [PATCH bpf-next v4 05/10] bpf, x86: refactor BPF_ST management in do_jit Alexis Lothoré (eBPF Foundation)
2026-07-08  8:00 ` [PATCH bpf-next v4 06/10] bpf, x86: emit KASAN checks into x86 JITed programs Alexis Lothoré (eBPF Foundation)
2026-07-08  8:16   ` sashiko-bot
2026-07-08 14:29     ` Alexis Lothoré
2026-07-08  8:00 ` [PATCH bpf-next v4 07/10] bpf, x86: enable KASAN for JITed programs on x86 Alexis Lothoré (eBPF Foundation)
2026-07-08  8:19   ` sashiko-bot
2026-07-08 14:33     ` Alexis Lothoré
2026-07-08  8:00 ` [PATCH bpf-next v4 08/10] selftests/bpf: add helper to check whether eBPF KASAN is active Alexis Lothoré (eBPF Foundation)
2026-07-08  8:00 ` [PATCH bpf-next v4 09/10] selftests/bpf: move bpf_jit_harden helper into testing_helpers Alexis Lothoré (eBPF Foundation)
2026-07-08  8:16   ` sashiko-bot
2026-07-08 14:43     ` Alexis Lothoré
2026-07-08  8:00 ` [PATCH bpf-next v4 10/10] selftests/bpf: add tests to validate KASAN on JIT programs Alexis Lothoré (eBPF Foundation)
2026-07-08  8:28   ` sashiko-bot
2026-07-08 14:47     ` Alexis Lothoré

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=20260708081008.402A51F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexis.lothore@bootlin.com \
    --cc=bpf@vger.kernel.org \
    --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