From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: "Alexis Lothoré (eBPF Foundation)" <alexis.lothore@bootlin.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"John Fastabend" <john.fastabend@gmail.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Thomas Gleixner" <tglx@kernel.org>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Shuah Khan" <shuah@kernel.org>, "Ingo Molnar" <mingo@redhat.com>,
"Andrey Konovalov" <andreyknvl@gmail.com>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Yafang Shao" <laoar.shao@gmail.com>
Cc: <ebpf@linuxfoundation.org>,
"Bastien Curutchet" <bastien.curutchet@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
<bpf@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH bpf-next v7 9/9] selftests/bpf: add tests to validate KASAN on JIT programs
Date: Mon, 24 Aug 2026 00:40:07 +0200 [thread overview]
Message-ID: <DKWONS3UI84A.382GORI5CXC51@gmail.com> (raw)
In-Reply-To: <20260822-kasan-v7-9-99afee6ef7fd@bootlin.com>
On Sat Aug 22, 2026 at 12:39 AM CEST, Alexis Lothoré (eBPF Foundation) wrote:
> Add a basic KASAN test runner that loads and test-run programs that can
> trigger memory management bugs. The test captures kernel logs and ensure
> that the expected KASAN splat is emitted by searching for the
> corresponding first lines in the report, hence validated that the needed
> instrumentation has been inserted by the JIT compiler before the
> relevant memory accesses. To allow each test to trigger the expected
> report, the kernel must run with the kasan_multi_shot configuration.
>
> The runner covers different cases and settings: in the nominal case, it
> validates kasan reports on basic instructions (on all supported accesses
> sizes) but also when report _should not_ be emitted (eg: for accesses on
> program stack). The runner also comes with a few specialized tests that
> are then not executed for all sizes/locations:
> - specific atomic ops
> - test for instructions involving different verifier states, with some
> states flagging memory as stack, and other states as non-stack memory
> - tests that validate the stack marking shifting when a patch is emitted
> by the verifier (zext/rnd_hi32, constant blindind).
> Most of those tests are able to trigger kasan reports by altering the
> shadow memory (triggering faulty accesses is otherwise complex, because
> of the verifier). A few tests trigger actual faulty accesses (eg
> out-of-bound accesses)
>
> A few of those tests depends on cpuv4 (load_acquire and store_release).
>
> # ./test_progs -a kasan
> #171/1 kasan/st_1_not_on_stack:OK
> #171/2 kasan/st_1_on_stack:OK
> #171/3 kasan/st_2_not_on_stack:OK
> #171/4 kasan/st_2_on_stack:OK
> #171/5 kasan/st_4_not_on_stack:OK
> #171/6 kasan/st_4_on_stack:OK
> #171/7 kasan/st_8_not_on_stack:OK
> #171/8 kasan/st_8_on_stack:OK
> #171/9 kasan/stx_1_not_on_stack:OK
> #171/10 kasan/stx_1_on_stack:OK
> #171/11 kasan/stx_2_not_on_stack:OK
> #171/12 kasan/stx_2_on_stack:OK
> #171/13 kasan/stx_4_not_on_stack:OK
> #171/14 kasan/stx_4_on_stack:OK
> #171/15 kasan/stx_8_not_on_stack:OK
> #171/16 kasan/stx_8_on_stack:OK
> #171/17 kasan/ldx_1_not_on_stack:OK
> #171/18 kasan/ldx_1_on_stack:OK
> #171/19 kasan/ldx_2_not_on_stack:OK
> #171/20 kasan/ldx_2_on_stack:OK
> #171/21 kasan/ldx_4_not_on_stack:OK
> #171/22 kasan/ldx_4_on_stack:OK
> #171/23 kasan/ldx_8_not_on_stack:OK
> #171/24 kasan/ldx_8_on_stack:OK
> #171/25 kasan/simple_atomic_4_not_on_stack:OK
> #171/26 kasan/simple_atomic_4_on_stack:OK
> #171/27 kasan/simple_atomic_8_not_on_stack:OK
> #171/28 kasan/simple_atomic_8_on_stack:OK
> #171/29 kasan/simple_atomic_fetch:OK
> #171/30 kasan/simple_atomic_fetch:OK
> #171/31 kasan/load_acquire_1_not_on_stack:SKIP
> #171/32 kasan/load_acquire_1_on_stack:SKIP
> #171/33 kasan/load_acquire_2_not_on_stack:SKIP
> #171/34 kasan/load_acquire_2_on_stack:SKIP
> #171/35 kasan/load_acquire_4_not_on_stack:SKIP
> #171/36 kasan/load_acquire_4_on_stack:SKIP
> #171/37 kasan/load_acquire_8_not_on_stack:SKIP
> #171/38 kasan/load_acquire_8_on_stack:SKIP
> #171/39 kasan/store_release_1_not_on_stack:SKIP
> #171/40 kasan/store_release_1_on_stack:SKIP
> #171/41 kasan/store_release_2_not_on_stack:SKIP
> #171/42 kasan/store_release_2_on_stack:SKIP
> #171/43 kasan/store_release_4_not_on_stack:SKIP
> #171/44 kasan/store_release_4_on_stack:SKIP
> #171/45 kasan/store_release_8_not_on_stack:SKIP
> #171/46 kasan/store_release_8_on_stack:SKIP
> #171/47 kasan/ldx_patched:OK
> #171/48 kasan/ldx_patched:OK
> #171/49 kasan/verifier_paths_stack_and_non_stack:OK
> #171/50 kasan/ldx_oob_1_not_on_stack:OK
> #171/51 kasan/ldx_oob_2_not_on_stack:OK
> #171/52 kasan/ldx_oob_4_not_on_stack:OK
> #171/53 kasan/ldx_oob_8_not_on_stack:OK
> #171/54 kasan/st_blinded:OK
> #171 kasan:OK (SKIP: 16/54)
> Summary: 1/38 PASSED, 16 SKIPPED, 0 FAILED
>
> Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
> ---
1. Should this test be made serial to make sure bpf_jit_harden sysctl change
doesn't affect other tests?
2. Clang currently collapses the intended ST/STX distinction for *_on_stack
tests: default/v3 emits STX for both pairs, cpuv4 emits ST for both, and the
default st_blinded object is already STX and therefore is not blinded. Please
check and assert that xlated insns are correct in the test itself if possible.
It might be necessary to use asm volatile assembly blocks in case you cannot
work around the compiler in C.
next prev parent reply other threads:[~2026-08-23 22:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 22:39 [PATCH bpf-next v7 0/9] bpf: add support for KASAN checks in JITed programs Alexis Lothoré (eBPF Foundation)
2026-08-21 22:39 ` [PATCH bpf-next v7 1/9] bpf: mark instructions accessing program stack Alexis Lothoré (eBPF Foundation)
2026-08-21 22:54 ` sashiko-bot
2026-08-21 23:24 ` bot+bpf-ci
2026-08-23 22:33 ` Kumar Kartikeya Dwivedi
2026-08-21 22:39 ` [PATCH bpf-next v7 2/9] bpf: add BPF_JIT_KASAN for KASAN instrumentation of JITed programs Alexis Lothoré (eBPF Foundation)
2026-08-21 22:39 ` [PATCH bpf-next v7 3/9] bpf, x86: refactor BPF_ST management in do_jit Alexis Lothoré (eBPF Foundation)
2026-08-21 22:39 ` [PATCH bpf-next v7 4/9] bpf, x86: emit KASAN checks in x86 JITed programs Alexis Lothoré (eBPF Foundation)
2026-08-21 23:24 ` bot+bpf-ci
2026-08-21 23:33 ` sashiko-bot
2026-08-23 22:30 ` Kumar Kartikeya Dwivedi
2026-08-21 22:39 ` [PATCH bpf-next v7 5/9] bpf, x86: enable KASAN for JITed programs on x86 Alexis Lothoré (eBPF Foundation)
2026-08-21 22:55 ` sashiko-bot
2026-08-21 22:39 ` [PATCH bpf-next v7 6/9] selftests/bpf: make cmdline_contains stricter Alexis Lothoré (eBPF Foundation)
2026-08-21 22:39 ` [PATCH bpf-next v7 7/9] selftests/bpf: add helpers for KASAN in JIT testing Alexis Lothoré (eBPF Foundation)
2026-08-21 22:39 ` [PATCH bpf-next v7 8/9] selftests/bpf: move bpf_jit_harden helper into testing_helpers Alexis Lothoré (eBPF Foundation)
2026-08-21 23:13 ` bot+bpf-ci
2026-08-21 22:39 ` [PATCH bpf-next v7 9/9] selftests/bpf: add tests to validate KASAN on JIT programs Alexis Lothoré (eBPF Foundation)
2026-08-21 23:36 ` bot+bpf-ci
2026-08-23 22:40 ` Kumar Kartikeya Dwivedi [this message]
2026-08-23 22:53 ` Kumar Kartikeya Dwivedi
2026-08-23 22:53 ` [PATCH bpf-next v7 0/9] bpf: add support for KASAN checks in JITed programs Kumar Kartikeya Dwivedi
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=DKWONS3UI84A.382GORI5CXC51@gmail.com \
--to=memxor@gmail.com \
--cc=alexis.lothore@bootlin.com \
--cc=andreyknvl@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bastien.curutchet@bootlin.com \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dave.hansen@linux.intel.com \
--cc=ebpf@linuxfoundation.org \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=hpa@zytor.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mingo@redhat.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tglx@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=x86@kernel.org \
--cc=yonghong.song@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.