diff options
author | Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> | 2021-08-05 19:12:36 +0900 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2021-12-16 15:54:38 -0800 |
commit | 90091c367e74d5b58d9ebe979cc363f7468f58d3 (patch) | |
tree | 8324365bb49bf7f4f210c7501ffa77bcf5f698c8 | |
parent | bc93a22a19eb2b68a16ecf04cdf4b2ed65aaf398 (diff) | |
download | linux-90091c367e74d5b58d9ebe979cc363f7468f58d3.tar.bz2 |
selftest/lkdtm: Skip stack-entropy test if lkdtm is not available
Exit with return code 4 if lkdtm is not available like other tests
in order to properly skip the test.
Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210805101236.1140381-1-misono.tomohiro@jp.fujitsu.com
-rwxr-xr-x | tools/testing/selftests/lkdtm/stack-entropy.sh | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/testing/selftests/lkdtm/stack-entropy.sh b/tools/testing/selftests/lkdtm/stack-entropy.sh index 1b4d95d575f8..14fedeef762e 100755 --- a/tools/testing/selftests/lkdtm/stack-entropy.sh +++ b/tools/testing/selftests/lkdtm/stack-entropy.sh @@ -4,13 +4,27 @@ # Measure kernel stack entropy by sampling via LKDTM's REPORT_STACK test. set -e samples="${1:-1000}" +TRIGGER=/sys/kernel/debug/provoke-crash/DIRECT +KSELFTEST_SKIP_TEST=4 + +# Verify we have LKDTM available in the kernel. +if [ ! -r $TRIGGER ] ; then + /sbin/modprobe -q lkdtm || true + if [ ! -r $TRIGGER ] ; then + echo "Cannot find $TRIGGER (missing CONFIG_LKDTM?)" + else + echo "Cannot write $TRIGGER (need to run as root?)" + fi + # Skip this test + exit $KSELFTEST_SKIP_TEST +fi # Capture dmesg continuously since it may fill up depending on sample size. log=$(mktemp -t stack-entropy-XXXXXX) dmesg --follow >"$log" & pid=$! report=-1 for i in $(seq 1 $samples); do - echo "REPORT_STACK" >/sys/kernel/debug/provoke-crash/DIRECT + echo "REPORT_STACK" > $TRIGGER if [ -t 1 ]; then percent=$(( 100 * $i / $samples )) if [ "$percent" -ne "$report" ]; then |