* [PATCH RESEND] riscv: fix kprobe __user string arg print fault issue
@ 2023-04-23 1:29 ruanjinjie
2023-04-23 8:56 ` Conor Dooley
0 siblings, 1 reply; 2+ messages in thread
From: ruanjinjie @ 2023-04-23 1:29 UTC (permalink / raw)
To: paul.walmsley, palmer, aou, linux-riscv, linux-kernel; +Cc: ruanjinjie
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: ruanjinjie <ruanjinjie@huawei.com>
---
arch/riscv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index eb7f29a412f8..c51f0d3227af 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -26,6 +26,7 @@ config RISCV
select ARCH_HAS_KCOV
select ARCH_HAS_MMIOWB
select ARCH_HAS_PMEM_API
+ select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_SET_DIRECT_MAP if MMU
select ARCH_HAS_SET_MEMORY if MMU
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH RESEND] riscv: fix kprobe __user string arg print fault issue
2023-04-23 1:29 [PATCH RESEND] riscv: fix kprobe __user string arg print fault issue ruanjinjie
@ 2023-04-23 8:56 ` Conor Dooley
0 siblings, 0 replies; 2+ messages in thread
From: Conor Dooley @ 2023-04-23 8:56 UTC (permalink / raw)
To: ruanjinjie, paul.walmsley, palmer, aou, linux-riscv, linux-kernel
Cc: ruanjinjie
On 23 April 2023 02:29:12 IST, ruanjinjie <ruanjinjie@huawei.com> wrote:
>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: ruanjinjie <ruanjinjie@huawei.com>
>---
> arch/riscv/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>index eb7f29a412f8..c51f0d3227af 100644
>--- a/arch/riscv/Kconfig
>+++ b/arch/riscv/Kconfig
>@@ -26,6 +26,7 @@ config RISCV
> select ARCH_HAS_KCOV
> select ARCH_HAS_MMIOWB
> select ARCH_HAS_PMEM_API
>+ select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
Please add this in alphabetical order, thanks.
> select ARCH_HAS_PTE_SPECIAL
> select ARCH_HAS_SET_DIRECT_MAP if MMU
> select ARCH_HAS_SET_MEMORY if MMU
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-23 8:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-23 1:29 [PATCH RESEND] riscv: fix kprobe __user string arg print fault issue ruanjinjie
2023-04-23 8:56 ` Conor Dooley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®