* [PATCH] selftests/ftrace: refactor eprobes test to fix argument checks
@ 2026-08-04 19:46 Martin Kaiser
2026-08-04 23:14 ` Masami Hiramatsu
0 siblings, 1 reply; 2+ messages in thread
From: Martin Kaiser @ 2026-08-04 19:46 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, Shuah Khan
Cc: Martin Kaiser, kernel test robot, linux-kernel,
linux-trace-kernel, linux-kselftest
The add/remove eprobe test installs an eprobe for the openat syscall and
runs ls. It checks the filenames that were opened by ls against a
whitelist and a blacklist.
Commit 206b25c09080 ("tracing: eprobe: read the complete FILTER_PTR_STRING
pointer") fixed access to some string fields in eprobes. This triggers
test failures as the blacklist does not allow relative paths for the
openat parameters.
What makes this test unstable is the fact that the openat calls vary a
lot between different systems.
Refactor the test to make it more robust. "cd <directory>" will issue a
chdir syscall with the target directory as parameter. Set an eprobe on
the sys_enter_chdir event and filter for the exact directory name. Allow
(fault) as fallback.
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202607151010.b68428e1-lkp@intel.com
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
.../ftrace/test.d/dynevent/add_remove_eprobe.tc | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc
index c300eb020262..e2322693d0c3 100644
--- a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc
+++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc
@@ -1,16 +1,16 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Generic dynamic event - add/remove eprobe events
-# requires: dynamic_events events/syscalls/sys_enter_openat "<attached-group>.<attached-event> [<args>]":README
+# requires: dynamic_events events/syscalls/sys_enter_chdir "<attached-group>.<attached-event> [<args>]":README
echo 0 > events/enable
clear_dynamic_events
SYSTEM="syscalls"
-EVENT="sys_enter_openat"
+EVENT="sys_enter_chdir"
FIELD="filename"
-EPROBE="eprobe_open"
+EPROBE="eprobe_chdir"
OPTIONS="file=+0(\$filename):ustring"
echo "e:$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
@@ -18,20 +18,14 @@ grep -q "$EPROBE" dynamic_events
test -d events/eprobes/$EPROBE
echo 1 > events/eprobes/$EPROBE/enable
-ls
+cd /sys/kernel/tracing
echo 0 > events/eprobes/$EPROBE/enable
-content=`grep '^ *ls-' trace | grep 'file='`
-nocontent=`grep '^ *ls-' trace | grep 'file=' | grep -v -e '"/' -e '"."' -e '(fault)' ` || true
-
+content=`grep -e 'file="/sys/kernel/tracing"\|(fault)' trace`
if [ -z "$content" ]; then
exit_fail
fi
-if [ ! -z "$nocontent" ]; then
- exit_fail
-fi
-
echo "-:$EPROBE" >> dynamic_events
! grep -q "$EPROBE" dynamic_events
--
2.43.7
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests/ftrace: refactor eprobes test to fix argument checks
2026-08-04 19:46 [PATCH] selftests/ftrace: refactor eprobes test to fix argument checks Martin Kaiser
@ 2026-08-04 23:14 ` Masami Hiramatsu
0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2026-08-04 23:14 UTC (permalink / raw)
To: Martin Kaiser
Cc: Steven Rostedt, Mathieu Desnoyers, Shuah Khan, kernel test robot,
linux-kernel, linux-trace-kernel, linux-kselftest
On Tue, 4 Aug 2026 21:46:35 +0200
Martin Kaiser <martin@kaiser.cx> wrote:
> The add/remove eprobe test installs an eprobe for the openat syscall and
> runs ls. It checks the filenames that were opened by ls against a
> whitelist and a blacklist.
>
> Commit 206b25c09080 ("tracing: eprobe: read the complete FILTER_PTR_STRING
> pointer") fixed access to some string fields in eprobes. This triggers
> test failures as the blacklist does not allow relative paths for the
> openat parameters.
>
> What makes this test unstable is the fact that the openat calls vary a
> lot between different systems.
>
> Refactor the test to make it more robust. "cd <directory>" will issue a
> chdir syscall with the target directory as parameter. Set an eprobe on
> the sys_enter_chdir event and filter for the exact directory name. Allow
> (fault) as fallback.
>
Looks good to me.
Fixes: 206b25c09080 ("tracing: eprobe: read the complete FILTER_PTR_STRING pointer")
Since it is already merged to linus tree.
Let me pick it.
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202607151010.b68428e1-lkp@intel.com
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Thanks!
> ---
> .../ftrace/test.d/dynevent/add_remove_eprobe.tc | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc
> index c300eb020262..e2322693d0c3 100644
> --- a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc
> +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc
> @@ -1,16 +1,16 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0
> # description: Generic dynamic event - add/remove eprobe events
> -# requires: dynamic_events events/syscalls/sys_enter_openat "<attached-group>.<attached-event> [<args>]":README
> +# requires: dynamic_events events/syscalls/sys_enter_chdir "<attached-group>.<attached-event> [<args>]":README
>
> echo 0 > events/enable
>
> clear_dynamic_events
>
> SYSTEM="syscalls"
> -EVENT="sys_enter_openat"
> +EVENT="sys_enter_chdir"
> FIELD="filename"
> -EPROBE="eprobe_open"
> +EPROBE="eprobe_chdir"
> OPTIONS="file=+0(\$filename):ustring"
> echo "e:$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
>
> @@ -18,20 +18,14 @@ grep -q "$EPROBE" dynamic_events
> test -d events/eprobes/$EPROBE
>
> echo 1 > events/eprobes/$EPROBE/enable
> -ls
> +cd /sys/kernel/tracing
> echo 0 > events/eprobes/$EPROBE/enable
>
> -content=`grep '^ *ls-' trace | grep 'file='`
> -nocontent=`grep '^ *ls-' trace | grep 'file=' | grep -v -e '"/' -e '"."' -e '(fault)' ` || true
> -
> +content=`grep -e 'file="/sys/kernel/tracing"\|(fault)' trace`
> if [ -z "$content" ]; then
> exit_fail
> fi
>
> -if [ ! -z "$nocontent" ]; then
> - exit_fail
> -fi
> -
> echo "-:$EPROBE" >> dynamic_events
>
> ! grep -q "$EPROBE" dynamic_events
> --
> 2.43.7
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-04 23:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 19:46 [PATCH] selftests/ftrace: refactor eprobes test to fix argument checks Martin Kaiser
2026-08-04 23:14 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox