selftests/lkdtm: Use "comm" instead of "diff" for dmesg
Subsystems (2)
PATCH 1/1 selftests/lkdtm: Use "comm" instead of "diff" for dmesg
Instead of full GNU diff (which smaller boot environments may not have), use "comm" which is more available.
--- tools/testing/selftests/lkdtm/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/lkdtm/run.sh +1 -1
@@ -82,7 +82,7 @@ dmesg > "$DMESG" ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true # Record and dump the results -dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true +dmesg | comm -13 "$DMESG" - > "$LOG" || true cat "$LOG" # Check for expected output
Signature · 5 lines
2.25.1 -- Kees Cook
Quoted 2 lines · Kees Cook
Instead of full GNU diff (which smaller boot environments may not have), use "comm" which is more available.
Although using "comm" requires CONFIG_PRINTK_TIME=y doesn't it?
Which is probably fine, but should be mentioned.
And I guess for completeness you could add:
tools/testing/selftests/lkdtm/config +1 -0
@@ -1 +1,2 @@ CONFIG_LKDTM=y +CONFIG_PRINTK_TIME=y
cheers
Quoted 27 lines
Reported-by Naresh Kamboju <[email protected]>Link https://lore.kernel.org/lkml/CA+G9fYtHP+Gg+BrR_GkBMxu2oOi-_e9pATtpb6TVRswv1G1r1Q@mail.gmail.com open hereFixes f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")Signed-off-by Kees Cook <[email protected]>--- tools/testing/selftests/lkdtm/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/lkdtm/run.sh +1
-1@@ -82,7 +82,7 @@ dmesg > "$DMESG" ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true # Record and dump the results -dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true +dmesg | comm -13 "$DMESG" - > "$LOG" || true cat "$LOG" # Check for expected outputSignature · 5 lines
2.25.1 -- Kees Cook
Quoted 5 lines · Michael Ellerman
Quoted 2 lines · Kees Cook
Instead of full GNU diff (which smaller boot environments may not have), use "comm" which is more available.
Although using "comm" requires
CONFIG_PRINTK_TIME=ydoesn't it?
No, it doesn't seem to. "comm" doesn't carry about the line prefixes. AIUI, the only reason for a mention of "sort" is because of how "comm" does its line pairing. i.e. as soon as it goes out of sync, it starts accounting for the disjunction between files. But that's exactly what we want it doing, and the prefix doesn't matter.
Signature · 1 line
Kees Cook
Quoted 5 lines · Kees Cook
Quoted 4 lines · Michael Ellerman
Quoted 2 lines · Kees Cook
Instead of full GNU diff (which smaller boot environments may not have), use "comm" which is more available.
Quoted 7 lines
Quoted 1 line
Although using "comm" requires
CONFIG_PRINTK_TIME=ydoesn't it?No, it doesn't seem to. "comm" doesn't carry about the line prefixes. AIUI, the only reason for a mention of "sort" is because of how "comm" does its line pairing. i.e. as soon as it goes out of sync, it starts accounting for the disjunction between files. But that's exactly what we want it doing, and the prefix doesn't matter.
OK, if it works.
cheers
Quoted 16 lines · Kees Cook
Instead of full GNU diff (which smaller boot environments may not have), use "comm" which is more available.
Reported-by Naresh Kamboju <[email protected]>Link https://lore.kernel.org/lkml/CA+G9fYtHP+Gg+BrR_GkBMxu2oOi-_e9pATtpb6TVRswv1G1r1Q@mail.gmail.com open hereFixes f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")Signed-off-by Kees Cook <[email protected]>--- tools/testing/selftests/lkdtm/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/lkdtm/run.sh +0
-0
tools/testing/selftests/lkdtm/run.sh dmesg > "$DMESG" · line 88
Quoted 8 lines
tools/testing/selftests/lkdtm/run.sh +1
-1@@ -82,7 +82,7 @@ dmesg > "$DMESG" ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true # Record and dump the results -dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true +dmesg | comm -13 "$DMESG" - > "$LOG" || true cat "$LOG" # Check for expected output
I'm not familiar with running lkdtm tests, but I copied the same fixup for the livepatching selftests and "comm" slides in nicely over there, so,
-- Joe
Quoted 7 lines · Kees Cook
Instead of full GNU diff (which smaller boot environments may not have), use "comm" which is more available.
Reported-by Naresh Kamboju <[email protected]>Link https://lore.kernel.org/lkml/CA+G9fYtHP+Gg+BrR_GkBMxu2oOi-_e9pATtpb6TVRswv1G1r1Q@mail.gmail.com open hereFixes f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")Signed-off-by Kees Cook <[email protected]>
Shuah, this really needs to land to fix lkdtm tests on busybox. Can you add this to -next? (Or is it better to direct this to Greg for the lkdtm tree?)
Thanks!
-Kees
Quoted 23 lines
--- tools/testing/selftests/lkdtm/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/lkdtm/run.sh +1
-1@@ -82,7 +82,7 @@ dmesg > "$DMESG" ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true # Record and dump the results -dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true +dmesg | comm -13 "$DMESG" - > "$LOG" || true cat "$LOG" # Check for expected outputSignature · 5 lines
2.25.1 -- Kees Cook
Signature · 1 line
Kees Cook
Quoted 33 lines · Kees Cook
Quoted 7 lines · Kees Cook
Instead of full GNU diff (which smaller boot environments may not have), use "comm" which is more available.
Reported-by Naresh Kamboju <[email protected]>Link https://lore.kernel.org/lkml/CA+G9fYtHP+Gg+BrR_GkBMxu2oOi-_e9pATtpb6TVRswv1G1r1Q@mail.gmail.com open hereFixes f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")Signed-off-by Kees Cook <[email protected]>Shuah, this really needs to land to fix lkdtm tests on busybox. Can you add this to -next? (Or is it better to direct this to Greg for the lkdtm tree?)
Thanks!
-Kees
Quoted 15 lines
--- tools/testing/selftests/lkdtm/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/lkdtm/run.sh +1
-1@@ -82,7 +82,7 @@ dmesg > "$DMESG" ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true # Record and dump the results -dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true +dmesg | comm -13 "$DMESG" - > "$LOG" || true
Quoted 9 lines
Quoted 8 lines
tools/testing/selftests/lkdtm/run.sh +0
-0cat "$LOG" # Check for expected outputSignature · 5 lines
2.25.1 -- Kees Cook
Hi Kees,
You may want to consider a similar follow up to the one Miroslav made to the livepatching equivalent:
https://lore.kernel.org/live-patching/[email protected]/T/#m1c17812d2c005dd57e9a299a4a492026a156619e
basically 'comm' will complain if two lines from dmesg have the same timestamp prefix and their text portions are not sorted.
Regards,
-- Joe
Quoted 44 lines · Joe Lawrence
Quoted 37 lines · Kees Cook
Quoted 7 lines · Kees Cook
Instead of full GNU diff (which smaller boot environments may not have), use "comm" which is more available.
Reported-by Naresh Kamboju <[email protected]>Link https://lore.kernel.org/lkml/CA+G9fYtHP+Gg+BrR_GkBMxu2oOi-_e9pATtpb6TVRswv1G1r1Q@mail.gmail.com open hereFixes f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")Signed-off-by Kees Cook <[email protected]>Shuah, this really needs to land to fix lkdtm tests on busybox. Can you add this to -next? (Or is it better to direct this to Greg for the lkdtm tree?)
Thanks!
-Kees
Quoted 19 lines
--- tools/testing/selftests/lkdtm/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/lkdtm/run.sh +1
-1@@ -82,7 +82,7 @@ dmesg > "$DMESG" ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true # Record and dump the results -dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true +dmesg | comm -13 "$DMESG" - > "$LOG" || true cat "$LOG" # Check for expected outputSignature · 1 line
2.25.1Quoted 3 lines
Quoted 2 lines
Signature · 1 line
Kees CookHi Kees,
Quoted 7 lines
You may want to consider a similar follow up to the one Miroslav made to the livepatching equivalent:
https://lore.kernel.org/live-patching/[email protected]/T/#m1c17812d2c005dd57e9a299a4a492026a156619e
basically 'comm' will complain if two lines from dmesg have the same timestamp prefix and their text portions are not sorted.
Ah-ha! Thank you. I will send a v2. :)
Signature · 1 line
Kees Cook
Quoted 5 lines · Kees Cook
Quoted 3 lines · Kees Cook
Instead of full GNU diff (which smaller boot environments may not have), use "comm" which is more available.
Quoted 9 lines
Quoted 4 lines
Reported-by Naresh Kamboju <[email protected]>Link https://lore.kernel.org/lkml/CA+G9fYtHP+Gg+BrR_GkBMxu2oOi-_e9pATtpb6TVRswv1G1r1Q@mail.gmail.com open hereFixes f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")Signed-off-by Kees Cook <[email protected]>Shuah, this really needs to land to fix lkdtm tests on busybox. Can you add this to -next? (Or is it better to direct this to Greg for the lkdtm tree?)
Kees, Thanks for the ping. I can queue this up in -next
Greg, would you like me to take this through selftest tree?
In case you want to take this through lkdtm tree:
thanks,
-- Shuah
Shuah Khan
maintainerQuoted 17 lines · Shuah Khan
Quoted 8 lines · Kees Cook
Quoted 6 lines · Kees Cook
Instead of full GNU diff (which smaller boot environments may not have), use "comm" which is more available.
Quoted 7 lines
Quoted 2 lines
Fixes f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")Signed-off-by Kees Cook <[email protected]>Shuah, this really needs to land to fix lkdtm tests on busybox. Can you add this to -next? (Or is it better to direct this to Greg for the lkdtm tree?)
Quoted 8 lines
Kees, Thanks for the ping. I can queue this up in -next
Greg, would you like me to take this through selftest tree?
In case you want to take this through lkdtm tree:
Acked-by Shuah Khan <[email protected]>
Kees,
Just saw your reply. Will wait for v2.
thanks,
-- Shuah