BPF List
 help / color / mirror / Atom feed
* a riscv ebpf uprobe can wedge the machine by writing pt_regs.status
@ 2026-11-16 17:35 rtm
  2026-11-16 18:37 ` Andrii Nakryiko
  2026-11-16 18:47 ` Alexei Starovoitov
  0 siblings, 2 replies; 4+ messages in thread
From: rtm @ 2026-11-16 17:35 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, John Fastabend; +Cc: bpf

On riscv, kprobe_prog_is_valid_access() allows a "uprobe" ebpf program
to write ctx at offset 256, which is pt_regs.status. When returning to
user space, ret_from_exception copies whatever value the ebpf program
provided to the CPU's sstatus. One way this can cause trouble is if
the ebpf program sets sstatus.SPP to 1, indicating that the trap
should return to user space in supervisor mode rather than user mode.

An ebpf program can do this if it starts with

  7a 01 00 01 00 01 00 00 

i.e. {code = 0x7a, dst_reg = 0x1, src_reg = 0x0, off = 0x100, imm = 0x100}

Robert Morris
rtm@mit.edu


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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 17:35 a riscv ebpf uprobe can wedge the machine by writing pt_regs.status rtm
2026-11-16 18:37 ` Andrii Nakryiko
2026-11-16 18:47 ` Alexei Starovoitov
2026-11-16 21:44   ` Jiri Olsa

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