Skip to content

bpf: Disable private stacks for uprobe programs

Jiri Olsa bpf stable 2 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 1 replyApplied 2/2
  2. v14 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- 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

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Reject multi kprobe programs in perf event attachkernel/events/core.c+11 -20 repliesApplied
2/2bpf: Disable private stacks for untagged kprobe programskernel/bpf/verifier.c tools/testing/selftests/bpf/progs/verifier_large_stack.c tools/testing/selftests/bpf/progs/verifier_private_stack.c+46 -31 replyApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCHv2 bpf-next 0/2] bpf: Disable private stacks for uprobe programs

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/[email protected]/

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(-)