Linux Kernel Selftest development
 help / color / mirror / Atom feed
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 v9 0/8] bpf: add support for KASAN checks in JITed programs
Date: Fri, 04 Sep 2026 11:02:34 +0200	[thread overview]
Message-ID: <DL6ESCNVJ52D.3NSNU8FZDQTU@gmail.com> (raw)
In-Reply-To: <20260903-kasan-v9-0-2407fe99255a@bootlin.com>

On Thu Sep 3, 2026 at 3:51 PM CEST, Alexis Lothoré (eBPF Foundation) wrote:
> Hello,
> this is v9 of the series aiming to bring basic support for KASAN checks
> to BPF JITed programs. Among a few minor optimizations, this revision
> fixes some wrong kasan instrumentation on some unwanted stack access
> (stack access ending up being instrumented AND targeting the wrong stack
> offset). To mitigate this risk further, this revision introduces a
> systematic KASAN check skip when (addr_reg == BPF_REG_FP || addr_reg ==
> BPF_REG_PARAMS) in emit_kasan_check. This secondary check (on top of the
> non_stack_access flag), should hopefully prevent the issues raised in
> v8. I've also reworked the emit_st refactoring to realign it with
> BPF_STX management in the x86 JIT compiler, as the "arguments on stack"
> feature made me realize that it could be kept more symmetric with
> BPF_STX; so I've dropped Ihor's Acked-by on this.
>
> Original cover letter:
>
> "Traditional" KASAN allows to spot memory management mistakes by
> reserving a fraction of memory as "shadow memory" that will map to the
> rest of the memory and allow its monitoring. Each memory-accessing
> instruction is then instrumented at build time to call some ASAN check
> function, that will analyze the corresponding bits in shadow memory, and
> if it detects the access as invalid, trigger a detailed report. The goal
> of this series is to replicate this mechanism for BPF programs when they
> are being JITed into native instructions: that's then the JIT compiler
> that is in charge of inserting calls to the corresponding kasan checks,
> when a program is being loaded into the kernel. This task involves:
> - identifying at program load time the instructions performing memory
>   accesses
> - identifying those accesses properties (size ? read or write ?) to
>   define the relevant kasan check function to call
> - just before the identified instructions:
>   - perform the basic context saving (ie: saving registers)
>   - inserting a call to the relevant kasan check function
>   - restore context
> - whenever the instrumented program executes, if it performs an invalid
>   access, it triggers a kasan report identical to those instrumented on
>   kernel side at build time.
>
> The series comes with new selftests programs that generate a wide
> variety of kasan reports: those need the kernel to be running with
> kasan_multi_shot enabled.
>
> As discussed in [1], this series is based on some choices and
> assumptions:
> - it focuses on x86_64 for now, and so only on KASAN_GENERIC
> - not all memory accessing BPF instructions are being instrumented:
>   - it discards instructions accessing BPF program stack (already
>     monitored by page guards)
>   - it discards possibly faulting instructions, like BPF_PROBE_MEM or
>     BPF_PROBE_ATOMIC insns
>

For the series:
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>

If there are remaining issues, we can fix forward, but I think we should try and
land this for now.

> [...]

  parent reply	other threads:[~2026-09-04  9:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 13:51 [PATCH bpf-next v9 0/8] bpf: add support for KASAN checks in JITed programs Alexis Lothoré (eBPF Foundation)
2026-09-03 13:51 ` [PATCH bpf-next v9 1/8] bpf: mark instructions accessing program stack Alexis Lothoré (eBPF Foundation)
2026-09-03 15:18   ` bot+bpf-ci
2026-09-03 13:51 ` [PATCH bpf-next v9 2/8] bpf: add BPF_JIT_KASAN for KASAN instrumentation of JITed programs Alexis Lothoré (eBPF Foundation)
2026-09-03 13:51 ` [PATCH bpf-next v9 3/8] bpf, x86: refactor BPF_ST management in do_jit Alexis Lothoré (eBPF Foundation)
2026-09-03 13:51 ` [PATCH bpf-next v9 4/8] bpf, x86: emit KASAN checks in x86 JITed programs Alexis Lothoré (eBPF Foundation)
2026-09-03 15:18   ` bot+bpf-ci
2026-09-03 13:51 ` [PATCH bpf-next v9 5/8] bpf, x86: enable KASAN for JITed programs on x86 Alexis Lothoré (eBPF Foundation)
2026-09-03 13:51 ` [PATCH bpf-next v9 6/8] selftests/bpf: make cmdline_contains stricter Alexis Lothoré (eBPF Foundation)
2026-09-03 13:51 ` [PATCH bpf-next v9 7/8] selftests/bpf: add helpers for KASAN in JIT testing Alexis Lothoré (eBPF Foundation)
2026-09-03 13:51 ` [PATCH bpf-next v9 8/8] selftests/bpf: add tests to validate KASAN on JIT programs Alexis Lothoré (eBPF Foundation)
2026-09-04  9:02 ` Kumar Kartikeya Dwivedi [this message]
2026-09-04 17:00 ` [PATCH bpf-next v9 0/8] bpf: add support for KASAN checks in JITed programs patchwork-bot+netdevbpf

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=DL6ESCNVJ52D.3NSNU8FZDQTU@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox