BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v1 0/3] Fix fastcall rewrite with indirect stack accesses
@ 2026-09-23  8:41 Kumar Kartikeya Dwivedi
  2026-09-23  8:41 ` [PATCH bpf-next v1 1/3] bpf: Check fastcall contract for helper and kfunc stack buffers Kumar Kartikeya Dwivedi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2026-09-23  8:41 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Eduard Zingerman, Emil Tsalapatis, kkd, kernel-team

When a bpf_fastcall call is inlined, the verifier removes the spill/fill
pairs around it and shrinks the stack frame to exclude their slots. Two
kinds of stack access skip the check that must disable this rewrite, so
the program can then access kernel stack outside its frame.

Patch 1 checks helper and kfunc stack buffers, which BPF CI reported
after commit 5da4a9f26fca ("bpf: Preserve stack initialization for
generic output buffers"). Patch 2 makes a callee's load from its
caller's stack check the caller's frame. Patch 3 adds tests.

Kumar Kartikeya Dwivedi (3):
  bpf: Check fastcall contract for helper and kfunc stack buffers
  bpf: Check fastcall contract of the frame a stack read targets
  selftests/bpf: Test fastcall rewrite with indirect stack accesses

 kernel/bpf/verifier.c                         |  10 +-
 .../bpf/progs/verifier_bpf_fastcall.c         | 161 ++++++++++++++++++
 2 files changed, 169 insertions(+), 2 deletions(-)


base-commit: 91f8613d95ad8cd99d8baf094806d1ef98bc6380
-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-24  5:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-23  8:41 [PATCH bpf-next v1 0/3] Fix fastcall rewrite with indirect stack accesses Kumar Kartikeya Dwivedi
2026-09-23  8:41 ` [PATCH bpf-next v1 1/3] bpf: Check fastcall contract for helper and kfunc stack buffers Kumar Kartikeya Dwivedi
2026-09-24  5:55   ` Alexei Starovoitov
2026-09-23  8:41 ` [PATCH bpf-next v1 2/3] bpf: Check fastcall contract of the frame a stack read targets Kumar Kartikeya Dwivedi
2026-09-23  8:41 ` [PATCH bpf-next v1 3/3] selftests/bpf: Test fastcall rewrite with indirect stack accesses Kumar Kartikeya Dwivedi
2026-09-23  9:33   ` bot+bpf-ci

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox