]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
riscv: kprobes: Fix probe address validation
authorFabian Vogt <fvogt@suse.de>
Wed, 10 Sep 2025 15:25:13 +0000 (17:25 +0200)
committerPaul Walmsley <pjw@kernel.org>
Fri, 10 Oct 2025 01:36:45 +0000 (19:36 -0600)
commit9e68bd803fac49274fde914466fd3b07c4d602c8
tree165f7102554fb236fd26f02ce55530f9b6a295b8
parentc199745d3ac3f836515a5734a6ca5c6f55a8809b
riscv: kprobes: Fix probe address validation

When adding a kprobe such as "p:probe/tcp_sendmsg _text+15392192",
arch_check_kprobe would start iterating all instructions starting from
_text until the probed address. Not only is this very inefficient, but
literal values in there (e.g. left by function patching) are
misinterpreted in a way that causes a desync.

Fix this by doing it like x86: start the iteration at the closest
preceding symbol instead of the given starting point.

Fixes: 87f48c7ccc73 ("riscv: kprobe: Fixup kernel panic when probing an illegal position")
Signed-off-by: Fabian Vogt <fvogt@suse.de>
Signed-off-by: Marvin Friedrich <marvin.friedrich@suse.com>
Acked-by: Guo Ren <guoren@kernel.org>
Link: https://lore.kernel.org/r/6191817.lOV4Wx5bFT@fvogt-thinkpad
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/kernel/probes/kprobes.c