BPF List
 help / color / mirror / Atom feed
* [PATCH bpf 0/2] bpf: Limit writable registers in uprobe context
@ 2026-11-18  8:44 Jiri Olsa
  2026-11-18  8:44 ` [PATCH bpf 1/2] bpf: Restrict uprobe ctx writes to the registers ptrace can set Jiri Olsa
  2026-11-18  8:44 ` [PATCH bpf 2/2] selftests/bpf: Test which ctx registers a uprobe prog can write Jiri Olsa
  0 siblings, 2 replies; 3+ messages in thread
From: Jiri Olsa @ 2026-11-18  8:44 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Masami Hiramatsu, Oleg Nesterov
  Cc: bpf, x86, linux-riscv, linux-arm-kernel, linux-trace-kernel,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	Will Deacon, Palmer Dabbelt, Peter Zijlstra, rtm

Hi,
a uprobe BPF program can currently write fields in struct pt_regs that
are loaded directly by the architecture’s return-to-user path. Some of
these fields are restricted by ptrace, but the BPF verifier does not
apply the same restrictions.

This series limits uprobe context writes to registers that ptrace can
set to arbitrary values. It adds architecture-specific writable-register
checks for arm64, riscv, and x86-64; other architectures default to
allowing no writes. Reads are unchanged.

The second patch adds verifier tests for writable and read-only registers
on x86-64, arm64, and riscv.

Patch 1 fixes the issue reported by rtm and is marked for stable consideration.
Patch 2 adds the regression tests.

thanks,
jirka


---
Jiri Olsa (2):
      bpf: Restrict uprobe ctx writes to the registers ptrace can set
      selftests/bpf: Test which ctx registers a uprobe prog can write

 arch/arm64/kernel/probes/uprobes.c                            |   6 ++
 arch/riscv/kernel/probes/uprobes.c                            |   6 ++
 arch/x86/kernel/uprobes.c                                     |  15 ++++
 include/linux/uprobes.h                                       |   5 ++
 kernel/events/uprobes.c                                       |   9 +++
 kernel/trace/bpf_trace.c                                      |  10 ++-
 tools/testing/selftests/bpf/prog_tests/verifier.c             |   2 +
 tools/testing/selftests/bpf/progs/verifier_uprobe_write_ctx.c | 196 +++++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 248 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_uprobe_write_ctx.c

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

end of thread, other threads:[~2026-11-18  8:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18  8:44 [PATCH bpf 0/2] bpf: Limit writable registers in uprobe context Jiri Olsa
2026-11-18  8:44 ` [PATCH bpf 1/2] bpf: Restrict uprobe ctx writes to the registers ptrace can set Jiri Olsa
2026-11-18  8:44 ` [PATCH bpf 2/2] selftests/bpf: Test which ctx registers a uprobe prog can write Jiri Olsa

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