BPF List
 help / color / mirror / Atom feed
From: "Alexis Lothoré" <alexis.lothore@bootlin.com>
To: sashiko-reviews@lists.linux.dev,
	"Alexis Lothoré (eBPF Foundation)" <alexis.lothore@bootlin.com>
Cc: <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next v6 9/9] selftests/bpf: add tests to validate KASAN on JIT programs
Date: Wed, 05 Aug 2026 10:24:57 +0200	[thread overview]
Message-ID: <DKGV77RFHLUM.1SCIGQ894DYQ3@bootlin.com> (raw)
In-Reply-To: <20260804183540.464031F000E9@smtp.kernel.org>

On Tue Aug 4, 2026 at 8:35 PM CEST, sashiko-bot wrote:

[...]

>> @@ -2449,6 +2583,11 @@ static int do_jit(struct bpf_verifier_env *env, struct bpf_prog *bpf_prog, int *
>>  				/* populate jmp_offset for JAE above to jump to start_of_ldx */
>>  				start_of_ldx = prog;
>>  				end_of_jmp[-1] = start_of_ldx - end_of_jmp;
>> +			} else if (!accesses_stack_only) {
>> +				err = emit_kasan_check(env, &prog, src_reg,
>> +						       insn, ip, false);
>> +				if (err)
>> +					return err;
>>  			}
>
> [Severity: High]
> Does this code emit KASAN checks for BPF_PROBE_MEM and BPF_PROBE_MEMSX
> instructions?
>
> Tracing programs frequently probe pointers that may be NULL or point to
> userspace memory using BPF_PROBE_MEM. The verifier emits these
> instructions to use the BPF exception table, which safely faults without
> crashing or logging.
>
> If emit_kasan_check() is called here unconditionally, it evaluates the
> pointer using __asan_load*, which will call kasan_report() on NULL or
> userspace pointers. Won't this bypass the exception table entirely and
> print a KASAN BUG report to dmesg for every expected invalid pointer,
> potentially causing log spam?

Aside from the usual r10/r11 complain: I am confused about why the bot
is raising this concern in an answer to the selftests patch, I guess it
should have been an answer to patch 4/9.

Anyway, no, this is not instrumenting BPF_PROBE_MEM/BPF_PROBE_MEMSX
insns, and it should not. We are in the else branch of the if
actually checking if we are dealing with PROBE_MEM/PROBE_MEMSX.

Alexis

-- 
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


      reply	other threads:[~2026-08-05  8:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 17:45 [PATCH bpf-next v6 0/9] bpf: add support for KASAN checks in JITed programs Alexis Lothoré (eBPF Foundation)
2026-08-04 17:45 ` [PATCH bpf-next v6 1/9] bpf: mark instructions accessing program stack Alexis Lothoré (eBPF Foundation)
2026-08-04 17:45 ` [PATCH bpf-next v6 2/9] bpf: add BPF_JIT_KASAN for KASAN instrumentation of JITed programs Alexis Lothoré (eBPF Foundation)
2026-08-04 17:45 ` [PATCH bpf-next v6 3/9] bpf, x86: refactor BPF_ST management in do_jit Alexis Lothoré (eBPF Foundation)
2026-08-04 19:04   ` bot+bpf-ci
2026-08-04 17:45 ` [PATCH bpf-next v6 4/9] bpf, x86: emit KASAN checks in x86 JITed programs Alexis Lothoré (eBPF Foundation)
2026-08-04 18:10   ` sashiko-bot
2026-08-04 17:45 ` [PATCH bpf-next v6 5/9] bpf, x86: enable KASAN for JITed programs on x86 Alexis Lothoré (eBPF Foundation)
2026-08-04 18:10   ` sashiko-bot
2026-08-04 17:45 ` [PATCH bpf-next v6 6/9] selftests/bpf: make cmdline_contains stricter Alexis Lothoré (eBPF Foundation)
2026-08-04 18:49   ` bot+bpf-ci
2026-08-04 17:45 ` [PATCH bpf-next v6 7/9] selftests/bpf: add helpers for KASAN in JIT testing Alexis Lothoré (eBPF Foundation)
2026-08-04 17:45 ` [PATCH bpf-next v6 8/9] selftests/bpf: move bpf_jit_harden helper into testing_helpers Alexis Lothoré (eBPF Foundation)
2026-08-04 17:45 ` [PATCH bpf-next v6 9/9] selftests/bpf: add tests to validate KASAN on JIT programs Alexis Lothoré (eBPF Foundation)
2026-08-04 18:35   ` sashiko-bot
2026-08-05  8:24     ` Alexis Lothoré [this message]

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=DKGV77RFHLUM.1SCIGQ894DYQ3@bootlin.com \
    --to=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