https://github.com/torvalds/linux
Revision 99a670b2069c725a7b50318aa681d9cae8f89325 authored by Ruan Jinjie on 04 May 2023, 07:29:10 UTC, committed by Palmer Dabbelt on 08 June 2023, 17:23:19 UTC
On riscv qemu platform, when add kprobe event on do_sys_open() to show filename string arg, it just print fault as follow: echo 'p:myprobe do_sys_open dfd=$arg1 filename=+0($arg2):string flags=$arg3 mode=$arg4' > kprobe_events bash-166 [000] ...1. 360.195367: myprobe: (do_sys_open+0x0/0x84) dfd=0xffffffffffffff9c filename=(fault) flags=0x8241 mode=0x1b6 bash-166 [000] ...1. 360.219369: myprobe: (do_sys_open+0x0/0x84) dfd=0xffffffffffffff9c filename=(fault) flags=0x8241 mode=0x1b6 bash-191 [000] ...1. 360.378827: myprobe: (do_sys_open+0x0/0x84) dfd=0xffffffffffffff9c filename=(fault) flags=0x98800 mode=0x0 As riscv do not select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE, the +0($arg2) addr is processed as a kernel address though it is a userspace address, cause the above filename=(fault) print. So select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE to avoid the issue, after that the kprobe trace is ok as below: bash-166 [000] ...1. 96.767641: myprobe: (do_sys_open+0x0/0x84) dfd=0xffffffffffffff9c filename="/dev/null" flags=0x8241 mode=0x1b6 bash-166 [000] ...1. 96.793751: myprobe: (do_sys_open+0x0/0x84) dfd=0xffffffffffffff9c filename="/dev/null" flags=0x8241 mode=0x1b6 bash-177 [000] ...1. 96.962354: myprobe: (do_sys_open+0x0/0x84) dfd=0xffffffffffffff9c filename="/sys/kernel/debug/tracing/events/kprobes/" flags=0x98800 mode=0x0 Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Acked-by: Björn Töpel <bjorn@rivosinc.com> Fixes: 0ebeea8ca8a4 ("bpf: Restrict bpf_probe_read{, str}() only to archs where they work") Link: https://lore.kernel.org/r/20230504072910.3742842-1-ruanjinjie@huawei.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 49a0a37
Tip revision: 99a670b2069c725a7b50318aa681d9cae8f89325 authored by Ruan Jinjie on 04 May 2023, 07:29:10 UTC
riscv: fix kprobe __user string arg print fault issue
riscv: fix kprobe __user string arg print fault issue
Tip revision: 99a670b
File | Mode | Size |
---|---|---|
.gitignore | -rw-r--r-- | 58 bytes |
Kconfig | -rw-r--r-- | 62.5 KB |
Makefile | -rw-r--r-- | 1.8 KB |
build-version | -rwxr-xr-x | 177 bytes |
calibrate.c | -rw-r--r-- | 8.6 KB |
do_mounts.c | -rw-r--r-- | 15.5 KB |
do_mounts.h | -rw-r--r-- | 908 bytes |
do_mounts_initrd.c | -rw-r--r-- | 3.7 KB |
do_mounts_rd.c | -rw-r--r-- | 7.7 KB |
init_task.c | -rw-r--r-- | 6.1 KB |
initramfs.c | -rw-r--r-- | 17.1 KB |
main.c | -rw-r--r-- | 38.6 KB |
noinitramfs.c | -rw-r--r-- | 862 bytes |
version-timestamp.c | -rw-r--r-- | 762 bytes |
version.c | -rw-r--r-- | 1.3 KB |
Computing file changes ...