Re: [PATCH] selftests/lkdtm: Use "comm" instead of "diff" for dmesg

From: Joe Lawrence
Date: Wed Sep 09 2020 - 16:30:03 EST

On 9/9/20 3:49 PM, Kees Cook wrote:

On Fri, Jun 26, 2020 at 01:59:43PM -0700, Kees Cook wrote:
Instead of full GNU diff (which smaller boot environments may not have),
use "comm" which is more available.

Reported-by: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx>
Fixes: f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")
Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>

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?)



tools/testing/selftests/lkdtm/ | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/lkdtm/ b/tools/testing/selftests/lkdtm/
index 8383eb89d88a..5fe23009ae13 100755
--- a/tools/testing/selftests/lkdtm/
+++ b/tools/testing/selftests/lkdtm/
@@ -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

Kees Cook

Hi Kees,

You may want to consider a similar follow up to the one Miroslav made to the livepatching equivalent:

basically 'comm' will complain if two lines from dmesg have the same timestamp prefix and their text portions are not sorted.


-- Joe