BPF List
 help / color / mirror / Atom feed
* [PATCHv2 bpf-next 0/2] bpf: Disable private stacks for uprobe programs
@ 2026-11-06 16:40 Jiri Olsa
  2026-11-06 16:40 ` [PATCHv2 bpf-next 1/2] bpf: Reject multi kprobe programs in perf event attach Jiri Olsa
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jiri Olsa @ 2026-11-06 16:40 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: bpf, Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	HyeongJun An, Christian Simon

hi,
uprobe programs can be preempted and re-entered on the same CPU. Since
the private stack is shared per program and CPU, a nested invocation can
overwrite the preempted invocation's stack.

This patch disables private stacks for KPROBE programs except kprobe multi
and kprobe-session programs, identified by the BPF_TRACE_KPROBE_MULTI and
BPF_TRACE_KPROBE_SESSION attach types. Standard kprobes lack an attach type,
and uprobes use different attach types or none, so they run without private
stacks.

It also rejects multi and session programs through the perf-event attach
path, which lacks their required run context and could allow a uprobe to
reach a private-stack tail-call target [1].

thanks,
jirka


v1: https://lore.kernel.org/bpf/20261103093400.112178-1-jolsa@kernel.org/

v2 changes:
- drop the BPF_TRACE_UPROBE attach type and fail perf event kprobe
  attach for kprobe-multi/uprobe-multi [Alexei]


[1] https://lore.kernel.org/bpf/aus-b8Lo2oCw_cGd@krava/
---
Jiri Olsa (2):
      bpf: Reject multi kprobe programs in perf event attach
      bpf: Disable private stacks for untagged kprobe programs

 kernel/bpf/verifier.c                                      |  9 +++++++
 kernel/events/core.c                                       | 13 ++++++++--
 tools/testing/selftests/bpf/progs/verifier_large_stack.c   |  2 +-
 tools/testing/selftests/bpf/progs/verifier_private_stack.c | 38 +++++++++++++++++++++++++++--
 4 files changed, 57 insertions(+), 5 deletions(-)

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

end of thread, other threads:[~2026-11-13 14:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 16:40 [PATCHv2 bpf-next 0/2] bpf: Disable private stacks for uprobe programs Jiri Olsa
2026-11-06 16:40 ` [PATCHv2 bpf-next 1/2] bpf: Reject multi kprobe programs in perf event attach Jiri Olsa
2026-11-06 16:40 ` [PATCHv2 bpf-next 2/2] bpf: Disable private stacks for untagged kprobe programs Jiri Olsa
2026-11-06 17:02   ` sashiko-bot
2026-11-06 17:17   ` bot+bpf-ci
2026-11-13 14:53   ` Jiri Olsa
2026-11-06 17:50 ` [PATCHv2 bpf-next 0/2] bpf: Disable private stacks for uprobe programs patchwork-bot+netdevbpf

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