selftest/livepatch: Only run test-kprobe with CONFIG_KPROBES_ON_FTRACE
Subsystems (2)
Song Liu
maintainerPATCH 1/1 selftest/livepatch: Only run test-kprobe with CONFIG_KPROBES_ON_FTRACE
CONFIG_KPROBES_ON_FTRACE is required for test-kprobe. Skip test-kprobe when CONFIG_KPROBES_ON_FTRACE is not set.
--- tools/testing/selftests/livepatch/test-kprobe.sh | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/livepatch/test-kprobe.sh +2 -0
@@ -5,6 +5,8 @@ . $(dirname $0)/functions.sh +zgrep KPROBES_ON_FTRACE /proc/config.gz || skip "test-kprobe requires CONFIG_KPROBES_ON_FTRACE" + MOD_LIVEPATCH=test_klp_livepatch MOD_KPROBE=test_klp_kprobe
Signature · 1 line
2.47.1
Joe Lawrence
maintainerQuoted 13 lines · Song Liu
CONFIG_KPROBES_ON_FTRACEis required for test-kprobe. Skip test-kprobe whenCONFIG_KPROBES_ON_FTRACEis not set.Signed-off-by Song Liu <[email protected]>--- tools/testing/selftests/livepatch/test-kprobe.sh | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/livepatch/test-kprobe.sh +0
-0
tools/testing/selftests/livepatch/test-kprobe.sh line 9
Quoted 5 lines
tools/testing/selftests/livepatch/test-kprobe.sh +2
-0@@ -5,6 +5,8 @@ . $(dirname $0)/functions.sh +zgrep KPROBES_ON_FTRACE /proc/config.gz || skip "test-kprobe requires CONFIG_KPROBES_ON_FTRACE" +
Hi Song,
This in turn depends on CONFIG_IKCONFIG_PROC for /proc/config.gz (not set for RHEL distro kernels).
Is there a dynamic way to figure out CONFIG_KPROBES_ON_FTRACE support? Without looking into it very long, maybe test_klp_kprobe.c's call to register_kprobe() could fail with -ENOTSUPP and the test script could gracefully skip the test?
Regards,
Signature · 1 line
Joe
Joe Lawrence
maintainerQuoted 22 lines · Joe Lawrence
Quoted 13 lines · Song Liu
CONFIG_KPROBES_ON_FTRACEis required for test-kprobe. Skip test-kprobe whenCONFIG_KPROBES_ON_FTRACEis not set.Signed-off-by Song Liu <[email protected]>--- tools/testing/selftests/livepatch/test-kprobe.sh | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/livepatch/test-kprobe.sh +0
-0tools/testing/selftests/livepatch/test-kprobe.sh line 9
Quoted 5 lines
tools/testing/selftests/livepatch/test-kprobe.sh +2
-0@@ -5,6 +5,8 @@ . $(dirname $0)/functions.sh +zgrep KPROBES_ON_FTRACE /proc/config.gz || skip "test-kprobe requires CONFIG_KPROBES_ON_FTRACE" +Hi Song,
Quoted 8 lines
This in turn depends on
CONFIG_IKCONFIG_PROCfor/proc/config.gz(not set for RHEL distro kernels).Is there a dynamic way to figure out
CONFIG_KPROBES_ON_FTRACEsupport? Without looking into it very long, maybe test_klp_kprobe.c's call toregister_kprobe()could fail with-ENOTSUPPand the test script could gracefully skip the test?
Ugh, n/m, looking at the code now I see it already does return -EOPNOTSUPP, but insmod throws out the code (if it even gets that far) and so it only reports success or failure. Graceful handling will have to be more clever than that.
Signature · 1 line
Joe
Song Liu
maintainerQuoted 18 lines · Joe Lawrence
Quoted 16 lines · Song Liu
CONFIG_KPROBES_ON_FTRACEis required for test-kprobe. Skip test-kprobe whenCONFIG_KPROBES_ON_FTRACEis not set.Signed-off-by Song Liu <[email protected]>--- tools/testing/selftests/livepatch/test-kprobe.sh | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/livepatch/test-kprobe.sh +0
-0@@ -5,6 +5,8 @@ . $(dirname $0)/functions.sh
Quoted 7 lines
tools/testing/selftests/livepatch/test-kprobe.sh line 9
Quoted 2 lines
tools/testing/selftests/livepatch/test-kprobe.sh +2
-0+zgrep KPROBES_ON_FTRACE /proc/config.gz || skip "test-kprobe requires CONFIG_KPROBES_ON_FTRACE" +Hi Song,
This in turn depends on
CONFIG_IKCONFIG_PROCfor/proc/config.gz(not set for RHEL distro kernels).
I was actually worrying about this when testing it.
Quoted 1 line
Is there a dynamic way to figure out
CONFIG_KPROBES_ON_FTRACEsupport?
How about we grep kprobe_ftrace_ops from /proc/kallsyms?
Thanks,
Song
Quoted 9 lines
Without looking into it very long, maybe test_klp_kprobe.c's call to
register_kprobe()could fail with-ENOTSUPPand the test script could gracefully skip the test?Regards,
--
Joe
Miroslav Benes
maintainerHi,
Quoted 24 lines · Song Liu
Quoted 23 lines · Joe Lawrence
Quoted 13 lines · Song Liu
CONFIG_KPROBES_ON_FTRACEis required for test-kprobe. Skip test-kprobe whenCONFIG_KPROBES_ON_FTRACEis not set.Signed-off-by Song Liu <[email protected]>--- tools/testing/selftests/livepatch/test-kprobe.sh | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/livepatch/test-kprobe.sh +0
-0tools/testing/selftests/livepatch/test-kprobe.sh line 9
Quoted 5 lines
tools/testing/selftests/livepatch/test-kprobe.sh +2
-0@@ -5,6 +5,8 @@ . $(dirname $0)/functions.sh +zgrep KPROBES_ON_FTRACE /proc/config.gz || skip "test-kprobe requires CONFIG_KPROBES_ON_FTRACE" +Hi Song,
Quoted 8 lines
Quoted 2 lines
This in turn depends on
CONFIG_IKCONFIG_PROCfor/proc/config.gz(not set for RHEL distro kernels).I was actually worrying about this when testing it.
Quoted 1 line
Is there a dynamic way to figure out
CONFIG_KPROBES_ON_FTRACEsupport?How about we grep
kprobe_ftrace_opsfrom/proc/kallsyms?
which relies on having KALLSYMS_ALL enabled but since CONFIG_LIVEPATCH depends on it, we are good. So I would say yes, it is a better option. Please, add a comment around.
Thank you,
Miroslav
Joe Lawrence
maintainerQuoted 33 lines · Miroslav Benes
Hi,
Quoted 29 lines · Song Liu
Quoted 18 lines · Joe Lawrence
Quoted 16 lines · Song Liu
CONFIG_KPROBES_ON_FTRACEis required for test-kprobe. Skip test-kprobe whenCONFIG_KPROBES_ON_FTRACEis not set.Signed-off-by Song Liu <[email protected]>--- tools/testing/selftests/livepatch/test-kprobe.sh | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/livepatch/test-kprobe.sh +0
-0@@ -5,6 +5,8 @@ . $(dirname $0)/functions.shQuoted 7 lines
tools/testing/selftests/livepatch/test-kprobe.sh line 9
Quoted 2 lines
tools/testing/selftests/livepatch/test-kprobe.sh +2
-0+zgrep KPROBES_ON_FTRACE /proc/config.gz || skip "test-kprobe requires CONFIG_KPROBES_ON_FTRACE" +Hi Song,
This in turn depends on
CONFIG_IKCONFIG_PROCfor/proc/config.gz(not set for RHEL distro kernels).I was actually worrying about this when testing it.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Is there a dynamic way to figure out
CONFIG_KPROBES_ON_FTRACEsupport?How about we grep
kprobe_ftrace_opsfrom/proc/kallsyms?which relies on having
KALLSYMS_ALLenabled but sinceCONFIG_LIVEPATCHdepends on it, we are good. So I would say yes, it is a better option. Please, add a comment around.
Kallsyms is a good workaround as kprobe_ftrace_ops should be stable (I hope :)
Since Song probably noticed this when upgrading and the new kprobes test unexpectedly failed, I'd add a Fixes tag to help out backporters:
but IMHO not worth rushing as important through the merge window.
Also, while poking at this today with virtme-ng, my initial attempt had build a fairly minimal kernel without CONFIG_DYNAMIC_DEBUG. We can also check for that via the sysfs interface to avoid confusing path-not-found msgs, like the following ...
-- Joe
-->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8-- -->8--
From c71f1966cfb7311bb1dde90c9f1be40704a253b6 Mon Sep 17 00:00:00 2001
From: Joe Lawrence <[email protected]>
Date: Tue, 18 Mar 2025 09:26:55 -0400
Subject: [PATCH] selftests/livepatch: check for CONFIG_DYNAMIC_DEBUG
Content-type: text/plain
The livepatch kselftests set and restore dynamic debug to verify subsystem behavior through expected printk messages. The tests should first check that this facility is available, otherwise just skip running.
--- tools/testing/selftests/livepatch/functions.sh | 3 +++ 1 file changed, 3 insertions(+)
tools/testing/selftests/livepatch/functions.sh +3 -0
@@ -58,6 +58,9 @@ function die() { } function push_config() { + if [[ ! -e "$SYSFS_DEBUG_DIR/dynamic_debug" ]]; then + skip "test requires CONFIG_DYNAMIC_DEBUG" + fi DYNAMIC_DEBUG=$(grep '^kernel/livepatch' "$SYSFS_DEBUG_DIR/dynamic_debug/control" | \ awk -F'[: ]' '{print "file " $1 " line " $2 " " $4}') FTRACE_ENABLED=$(sysctl --values kernel.ftrace_enabled)
Signature · 1 line
2.42.0
Song Liu
maintainerQuoted 52 lines · Joe Lawrence
Quoted 33 lines · Miroslav Benes
Hi,
Quoted 29 lines · Song Liu
Quoted 18 lines · Joe Lawrence
Quoted 16 lines · Song Liu
CONFIG_KPROBES_ON_FTRACEis required for test-kprobe. Skip test-kprobe whenCONFIG_KPROBES_ON_FTRACEis not set.Signed-off-by Song Liu <[email protected]>--- tools/testing/selftests/livepatch/test-kprobe.sh | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/livepatch/test-kprobe.sh +0
-0@@ -5,6 +5,8 @@ . $(dirname $0)/functions.shQuoted 7 lines
tools/testing/selftests/livepatch/test-kprobe.sh line 9
Quoted 2 lines
tools/testing/selftests/livepatch/test-kprobe.sh +2
-0+zgrep KPROBES_ON_FTRACE /proc/config.gz || skip "test-kprobe requires CONFIG_KPROBES_ON_FTRACE" +Hi Song,
This in turn depends on
CONFIG_IKCONFIG_PROCfor/proc/config.gz(not set for RHEL distro kernels).I was actually worrying about this when testing it.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Is there a dynamic way to figure out
CONFIG_KPROBES_ON_FTRACEsupport?How about we grep
kprobe_ftrace_opsfrom/proc/kallsyms?which relies on having
KALLSYMS_ALLenabled but sinceCONFIG_LIVEPATCHdepends on it, we are good. So I would say yes, it is a better option. Please, add a comment around.Kallsyms is a good workaround as
kprobe_ftrace_opsshould be stable (I hope :)Since Song probably noticed this when upgrading and the new kprobes test unexpectedly failed, I'd add a Fixes tag to help out backporters:
Fixes 62597edf6340 ("selftests: livepatch: test livepatching a kprobed function")
Quoted 7 lines
but IMHO not worth rushing as important through the merge window.
Also, while poking at this today with virtme-ng, my initial attempt had build a fairly minimal kernel without
CONFIG_DYNAMIC_DEBUG. We can also check for that via the sysfs interface to avoid confusing path-not-found msgs, like the following ...
We already have CONFIG_DYNAMIC_DEBUG=y in tools/testing/selftests/livepatch, so I think we don't need to check that again.
We cannot do the same for CONFIG_KPROBES_ON_FTRACE, because we still want to run other tests on systems that do not support CONFIG_KPROBES_ON_FTRACE.
Thanks,
Song
Joe Lawrence
maintainerQuoted 56 lines · Song Liu
Quoted 55 lines · Joe Lawrence
Quoted 33 lines · Miroslav Benes
Hi,
Quoted 29 lines · Song Liu
Quoted 18 lines · Joe Lawrence
Quoted 16 lines · Song Liu
CONFIG_KPROBES_ON_FTRACEis required for test-kprobe. Skip test-kprobe whenCONFIG_KPROBES_ON_FTRACEis not set.Signed-off-by Song Liu <[email protected]>--- tools/testing/selftests/livepatch/test-kprobe.sh | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/livepatch/test-kprobe.sh +0
-0@@ -5,6 +5,8 @@ . $(dirname $0)/functions.shQuoted 7 lines
tools/testing/selftests/livepatch/test-kprobe.sh line 9
Quoted 2 lines
tools/testing/selftests/livepatch/test-kprobe.sh +2
-0+zgrep KPROBES_ON_FTRACE /proc/config.gz || skip "test-kprobe requires CONFIG_KPROBES_ON_FTRACE" +Hi Song,
This in turn depends on
CONFIG_IKCONFIG_PROCfor/proc/config.gz(not set for RHEL distro kernels).I was actually worrying about this when testing it.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Is there a dynamic way to figure out
CONFIG_KPROBES_ON_FTRACEsupport?How about we grep
kprobe_ftrace_opsfrom/proc/kallsyms?which relies on having
KALLSYMS_ALLenabled but sinceCONFIG_LIVEPATCHdepends on it, we are good. So I would say yes, it is a better option. Please, add a comment around.Kallsyms is a good workaround as
kprobe_ftrace_opsshould be stable (I hope :)Since Song probably noticed this when upgrading and the new kprobes test unexpectedly failed, I'd add a Fixes tag to help out backporters:
Fixes 62597edf6340 ("selftests: livepatch: test livepatching a kprobed function")but IMHO not worth rushing as important through the merge window.
Quoted 8 lines
Quoted 4 lines
Also, while poking at this today with virtme-ng, my initial attempt had build a fairly minimal kernel without
CONFIG_DYNAMIC_DEBUG. We can also check for that via the sysfs interface to avoid confusing path-not-found msgs, like the following ...We already have
CONFIG_DYNAMIC_DEBUG=yintools/testing/selftests/livepatch, so I think we don't need to check that again.
Ah right. Do you know what script/file reads or sources that file? (It's such a generic term that I get a bazillion grep hits.) When I run make -C tools/testing/selftests/livepatch run_tests it just builds and runs the tests regardless of the actual config.
Signature · 1 line
Joe
Song Liu
maintainerOn Tue, Mar 18, 2025 at 10:18 AM Joe Lawrence <[email protected]> wrote:
[...]
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Also, while poking at this today with virtme-ng, my initial attempt had build a fairly minimal kernel without
CONFIG_DYNAMIC_DEBUG. We can also check for that via the sysfs interface to avoid confusing path-not-found msgs, like the following ...
Quoted 8 lines
Quoted 3 lines
We already have
CONFIG_DYNAMIC_DEBUG=yintools/testing/selftests/livepatch, so I think we don't need to check that again.Ah right. Do you know what script/file reads or sources that file? (It's such a generic term that I get a bazillion grep hits.) When I run
make -C tools/testing/selftests/livepatch run_testsit just builds and runs the tests regardless of the actual config.
I am not aware of any script reading the config file. It appears to be a convention that many subsystems follow. The subsystems may have some CI that reads these config files. Some subsystems use more complex logic around these config files. For example, bpf selftests have 6 config files and 4 DENYLIST.
Thanks,
Song
Song Liu
maintainerOn Tue, Mar 18, 2025 at 6:45 AM Joe Lawrence <[email protected]> wrote:
[...]
Quoted 9 lines
Kallsyms is a good workaround as
kprobe_ftrace_opsshould be stable (I hope :)Since Song probably noticed this when upgrading and the new kprobes test unexpectedly failed, I'd add a Fixes tag to help out backporters:
Fixes 62597edf6340 ("selftests: livepatch: test livepatching a kprobed function")but IMHO not worth rushing as important through the merge window.
I actually think this fix is simple enough that I would not worry about it breaking anything in 6.15. But if other folks agree this is too late for 6.15, I don't mind waiting until 6.16.
Thanks,
Song