[PATCH v3 0/2] riscv: probes: reject probes inside an LR/SC sequence

From: Vladimir Kondratiev

Date: Thu Nov 12 2026 - 05:34:03 EST


Patch 1 fixes page fault reported by sashiko-bot@xxxxxxxxxx that
existed before this patch series

Patch 2 rejects probes inside the LR/SC sequence. This commit was
submitted as patch 1 of the series [1].
Detaching it from that series with slightly edited commit message,
because it is not depending on other stuff.

[1] https://patch.msgid.link/20261110-lrsc-only-v6-0-bafc3cc0fcae@xxxxxxxxxxxx

---
Changes in v3:
- Fix lr/sc loop detection logic for lr at probe position
- Add "Fixes" trailers as suggested by sashiko-bot@xxxxxxxxxx
- Link to v2: https://patch.msgid.link/20261111-probes-in-lrsc-v2-0-b2525b7e1e8e@xxxxxxxxxxxx

Changes in v2:
- Allow kprobe on the LR itself unless it is part of the LR/SC loop.
- Fix error (reported by sashiko-bot@xxxxxxxxxx) where
arch_prepare_kprobe() returns -EILSEQ for LR/SC probes.
Make codes returned by arch_check_kprobe to indicate -EINVAL
if probe falls within the LR/SC loop, consistent with the case when
INSN_REJECTED returned by riscv_probe_decode_insn
- add patch fixing out-of-bounds read in riscv_probe_decode_insn()
reported by sashiko-bot@xxxxxxxxxx (as patch 1)
- Link to v1: https://patch.msgid.link/20261111-probes-in-lrsc-v1-1-4f99ddea5f68@xxxxxxxxxxxx

To: Paul Walmsley <pjw@xxxxxxxxxx>
To: Palmer Dabbelt <palmer@xxxxxxxxxxx>
To: Albert Ou <aou@xxxxxxxxxxxxxxxxx>
To: Alexandre Ghiti <alex@xxxxxxxx>
To: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
To: Oleg Nesterov <oleg@xxxxxxxxxx>
To: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
To: Guo Ren <guoren@xxxxxxxxxx>
To: Pekka Enberg <penberg@xxxxxxxxxx>
To: Patrick Stählin <me@xxxxxxxx>
Cc: linux-riscv@xxxxxxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-trace-kernel@xxxxxxxxxxxxxxx
Cc: Palmer Dabbelt <palmerdabbelt@xxxxxxxxxx>
Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@xxxxxxxxxxxx>

---
Vladimir Kondratiev (2):
riscv: kprobes: fix out-of-bounds read in riscv_probe_decode_insn
riscv: probes: reject probes inside an LR/SC sequence

arch/riscv/include/asm/insn.h | 28 +++++++++++
arch/riscv/kernel/probes/decode-insn.c | 91 ++++++++++++++++++++++++++++++++++
arch/riscv/kernel/probes/decode-insn.h | 7 +++
arch/riscv/kernel/probes/kprobes.c | 29 +++++++----
arch/riscv/kernel/probes/uprobes.c | 31 ++++++++++++
5 files changed, 177 insertions(+), 9 deletions(-)
---
base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
change-id: 20261111-probes-in-lrsc-4ccde6cbf436

Best regards,
--
Vladimir Kondratiev <vladimir.kondratiev@xxxxxxxxxxxx>