bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/4] uprobe,bpf: Allow to change app registers from uprobe
@ 2025-08-01 21:02 Jiri Olsa
  2025-08-01 21:02 ` [RFC 1/4] uprobe: Do not emulate/sstep original instruction when ip is changed Jiri Olsa
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Jiri Olsa @ 2025-08-01 21:02 UTC (permalink / raw)
  To: Oleg Nesterov, Masami Hiramatsu, Peter Zijlstra, Andrii Nakryiko
  Cc: bpf, linux-kernel, linux-trace-kernel, x86, Song Liu,
	Yonghong Song, John Fastabend, Hao Luo, Steven Rostedt,
	Ingo Molnar

hi,
we recently had several requests for tetragon to be able to change
user application function return value or divert its execution through
instruction pointer change.

This *RFC* patchset adds support for uprobe program to change app's
registers including instruction pointer.

There's a hiccup with instruction pointer change.. if uprobe handler
changes instruction pointer, the current code will still execute the
original instruction and increment the (new) ip with its length.

This makes the new instruction pointer bogus and application will
likely crash on illegal instruction execution.

I think if user decides to take execution elsewhere, we can skip
original instruction execution (patch#1), but I might be easily
wrong and overlooking something.. hence RFC ;-)

thoughts? thanks,
jirka


---
Jiri Olsa (4):
      uprobe: Do not emulate/sstep original instruction when ip is changed
      bpf: Allow uprobe program to change context registers
      selftests/bpf: Add uprobe context registers changes test
      selftests/bpf: Add uprobe context ip register change test

 include/linux/bpf.h                             |   1 +
 kernel/events/core.c                            |   4 +++
 kernel/events/uprobes.c                         |   3 ++
 kernel/trace/bpf_trace.c                        |   3 +-
 tools/testing/selftests/bpf/prog_tests/uprobe.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 tools/testing/selftests/bpf/progs/test_uprobe.c |  38 ++++++++++++++++++++++++
 6 files changed, 208 insertions(+), 3 deletions(-)

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

end of thread, other threads:[~2025-08-08 18:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-01 21:02 [RFC 0/4] uprobe,bpf: Allow to change app registers from uprobe Jiri Olsa
2025-08-01 21:02 ` [RFC 1/4] uprobe: Do not emulate/sstep original instruction when ip is changed Jiri Olsa
2025-08-02 10:34   ` Oleg Nesterov
2025-08-04  8:12     ` Jiri Olsa
2025-08-08 18:38       ` Jiri Olsa
2025-08-01 21:02 ` [RFC 2/4] bpf: Allow uprobe program to change context registers Jiri Olsa
2025-08-01 21:02 ` [RFC 3/4] selftests/bpf: Add uprobe context registers changes test Jiri Olsa
2025-08-01 21:02 ` [RFC 4/4] selftests/bpf: Add uprobe context ip register change test Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).