selftests/ftrace: check for do_sys_openat2 in user-memory test
Subsystems (3)
PATCH 1/1 selftests/ftrace: check for do_sys_openat2 in user-memory test
From: Colin Ian King <[email protected]>
More recent libc implementations are now using openat/openat2 system calls so also add do_sys_openat2 to the tracing so that the test passes on these systems because do_sys_open may not be called.
--- .../testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +2 -0
@@ -9,6 +9,8 @@ grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported :;: "user-memory access syntax and ustring working on user memory";: echo 'p:myevent do_sys_open path=+0($arg2):ustring path2=+u0($arg2):string' \ > kprobe_events +echo 'p:myevent2 do_sys_openat2 path=+0($arg2):ustring path2=+u0($arg2):string' \ + > kprobe_events grep myevent kprobe_events | \ grep -q 'path=+0($arg2):ustring path2=+u0($arg2):string'
Signature · 1 line
2.27.0
Steven Rostedt
maintainerQuoted 16 lines · On Thu, 1 Oct 2020 09:56:41 +0100 Colin King <[email protected]> wrote:
From: Colin Ian King <[email protected]>
More recent libc implementations are now using openat/openat2 system calls so also add
do_sys_openat2to the tracing so that the test passes on these systems becausedo_sys_openmay not be called.Signed-off-by Colin Ian King <[email protected]>--- .../testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +0
-0
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported · line 14
Quoted 6 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +2
-0@@ -9,6 +9,8 @@ grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported :;: "user-memory access syntax and ustring working on user memory";: echo 'p:myevent do_sys_open path=+0($arg2):ustring path2=+u0($arg2):string' \ > kprobe_events +echo 'p:myevent2 do_sys_openat2 path=+0($arg2):ustring path2=+u0($arg2):string' \ + > kprobe_events
This still wont work, because the rest of the code only enables the myevent event, and not the one you just added.
Did you see this broken before, and this patch fixes it?
-- Steve
Quoted 2 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +0
-0grep myevent kprobe_events | \ grep -q 'path=+0($arg2):ustring path2=+u0($arg2):string'
Quoted 14 lines · Steven Rostedt
Quoted 11 lines · On Thu, 1 Oct 2020 09:56:41 +0100 Colin King <[email protected]> wrote:
From: Colin Ian King <[email protected]>
More recent libc implementations are now using openat/openat2 system calls so also add
do_sys_openat2to the tracing so that the test passes on these systems becausedo_sys_openmay not be called.Signed-off-by Colin Ian King <[email protected]>--- .../testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc | 2 ++ 1 file changed, 2 insertions(+)
Quoted 14 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported · line 14
Quoted 11 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +2
-0@@ -9,6 +9,8 @@ grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported :;: "user-memory access syntax and ustring working on user memory";: echo 'p:myevent do_sys_open path=+0($arg2):ustring path2=+u0($arg2):string' \ > kprobe_events +echo 'p:myevent2 do_sys_openat2 path=+0($arg2):ustring path2=+u0($arg2):string' \ + > kprobe_eventsThis still wont work, because the rest of the code only enables the myevent event, and not the one you just added.
Yep, I botched this and tested the wrong fix.
Quoted 2 lines
Did you see this broken before, and this patch fixes it?
So this test breaks with a recent libc and support tools built against libc. I believe the do_sys_open is not being detected because do_sys_openat2 is being called instead.
Not sure now of the correct way to fix this.
Quoted 7 lines
-- Steve
Quoted 2 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +0
-0grep myevent kprobe_events | \ grep -q 'path=+0($arg2):ustring path2=+u0($arg2):string'
Steven Rostedt
maintainerQuoted 5 lines · On Thu, 1 Oct 2020 16:40:33 +0100 Colin Ian King <[email protected]>…
So this test breaks with a recent libc and support tools built against libc. I believe the
do_sys_openis not being detected becausedo_sys_openat2is being called instead.Not sure now of the correct way to fix this.
Perhaps by enabling both events?
-- Steve
Masami Hiramatsu
maintainerQuoted 33 lines · On Thu, 1 Oct 2020 16:40:33 +0100 Colin Ian King <[email protected]>…
Quoted 14 lines · Steven Rostedt
Quoted 11 lines · On Thu, 1 Oct 2020 09:56:41 +0100 Colin King <[email protected]> wrote:
From: Colin Ian King <[email protected]>
More recent libc implementations are now using openat/openat2 system calls so also add
do_sys_openat2to the tracing so that the test passes on these systems becausedo_sys_openmay not be called.Signed-off-by Colin Ian King <[email protected]>--- .../testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc | 2 ++ 1 file changed, 2 insertions(+)Quoted 14 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported · line 14
Quoted 11 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +2
-0@@ -9,6 +9,8 @@ grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported :;: "user-memory access syntax and ustring working on user memory";: echo 'p:myevent do_sys_open path=+0($arg2):ustring path2=+u0($arg2):string' \ > kprobe_events +echo 'p:myevent2 do_sys_openat2 path=+0($arg2):ustring path2=+u0($arg2):string' \ + > kprobe_eventsThis still wont work, because the rest of the code only enables the myevent event, and not the one you just added.
Yep, I botched this and tested the wrong fix.
Quoted 1 line
Quoted 7 lines
Quoted 1 line
Did you see this broken before, and this patch fixes it?
So this test breaks with a recent libc and support tools built against libc. I believe the
do_sys_openis not being detected becausedo_sys_openat2is being called instead.Not sure now of the correct way to fix this.
Hmm, this actually just try to catch the user-string. So the another function which accepts any user-string, is OK.
Let me try to use another one.
Thank you for reporting!
Quoted 9 lines
Quoted 8 lines
-- Steve
Quoted 2 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +0
-0grep myevent kprobe_events | \ grep -q 'path=+0($arg2):ustring path2=+u0($arg2):string'
Signature · 1 line
Masami Hiramatsu <[email protected]>
Masami Hiramatsu
maintainerQuoted 16 lines · On Thu, 1 Oct 2020 09:56:41 +0100 Colin King <[email protected]> wrote:
From: Colin Ian King <[email protected]>
More recent libc implementations are now using openat/openat2 system calls so also add
do_sys_openat2to the tracing so that the test passes on these systems becausedo_sys_openmay not be called.Signed-off-by Colin Ian King <[email protected]>--- .../testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +0
-0
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported · line 11
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +0
-0@@ -9,6 +9,8 @@ grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported :;: "user-memory access syntax and ustring working on user memory";: echo 'p:myevent do_sys_open path=+0($arg2):ustring path2=+u0($arg2):string' \ > kprobe_events
OK, at first, you need to check the kernel has do_sys_openat2 from /proc/kallsyms (grep -qw will help you), because it is new syscall.
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported · line 13
Quoted 2 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +2
-0+echo 'p:myevent2 do_sys_openat2 path=+0($arg2):ustring path2=+u0($arg2):string' \ + > kprobe_events
Also, you need to append (">>") it instead overwrite (">") to kprobe_events.
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported · line 16
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +0
-0grep myevent kprobe_events | \ grep -q 'path=+0($arg2):ustring path2=+u0($arg2):string'
And also you have to enable both myevent and myevent2 (if exists) after this.
Then I think your patch will work correctly.
Thank you!
Signature · 1 line
Masami Hiramatsu <[email protected]>
Quoted 32 lines · Masami Hiramatsu
Quoted 16 lines · On Thu, 1 Oct 2020 09:56:41 +0100 Colin King <[email protected]> wrote:
From: Colin Ian King <[email protected]>
More recent libc implementations are now using openat/openat2 system calls so also add
do_sys_openat2to the tracing so that the test passes on these systems becausedo_sys_openmay not be called.Signed-off-by Colin Ian King <[email protected]>--- .../testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +0
-0tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported · line 11
Quoted 3 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +0
-0@@ -9,6 +9,8 @@ grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported :;: "user-memory access syntax and ustring working on user memory";: echo 'p:myevent do_sys_open path=+0($arg2):ustring path2=+u0($arg2):string' \ > kprobe_eventsOK, at first, you need to check the kernel has
do_sys_openat2from/proc/kallsyms(grep -qw will help you), because it is new syscall.tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported · line 13
Quoted 2 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc +2
-0+echo 'p:myevent2 do_sys_openat2 path=+0($arg2):ustring path2=+u0($arg2):string' \ + > kprobe_eventsAlso, you need to append (">>") it instead overwrite (">") to
kprobe_events.Quoted 1 line
Quoted 7 lines
Quoted 2 lines
grep myevent
kprobe_events| \
grep -q 'path=+0($arg2):ustring path2=+u0($arg2):string'And also you have to enable both myevent and myevent2 (if exists) after this.
Then I think your patch will work correctly.
Indeed, thanks. I'll send a V2 shortly.
Quoted 3 lines
Thank you!