Skip to content

Commit 456ff66

Browse files
committed
Merge: Updates for lkdtm selftests
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5439 Description: Updates for lkdtm selftests JIRA: https://issues.redhat.com/browse/RHEL-52232 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=65130378 Tested: Verified Brew build test kernel RPMs and confirmed issue is resovled Signed-off-by: Mamatha Inamdar <[email protected]> commit 90091c3 Author: Misono Tomohiro <[email protected]> Date: Thu Aug 5 19:12:36 2021 +0900 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 <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mamatha Inamdar <[email protected]> Approved-by: Steve Best <[email protected]> Approved-by: Tony Camuso <[email protected]> Approved-by: Desnes Nunes <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Rado Vrbovsky <[email protected]>
2 parents 191f608 + 7a2d503 commit 456ff66

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tools/testing/selftests/lkdtm/stack-entropy.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,27 @@
44
# Measure kernel stack entropy by sampling via LKDTM's REPORT_STACK test.
55
set -e
66
samples="${1:-1000}"
7+
TRIGGER=/sys/kernel/debug/provoke-crash/DIRECT
8+
KSELFTEST_SKIP_TEST=4
9+
10+
# Verify we have LKDTM available in the kernel.
11+
if [ ! -r $TRIGGER ] ; then
12+
/sbin/modprobe -q lkdtm || true
13+
if [ ! -r $TRIGGER ] ; then
14+
echo "Cannot find $TRIGGER (missing CONFIG_LKDTM?)"
15+
else
16+
echo "Cannot write $TRIGGER (need to run as root?)"
17+
fi
18+
# Skip this test
19+
exit $KSELFTEST_SKIP_TEST
20+
fi
721

822
# Capture dmesg continuously since it may fill up depending on sample size.
923
log=$(mktemp -t stack-entropy-XXXXXX)
1024
dmesg --follow >"$log" & pid=$!
1125
report=-1
1226
for i in $(seq 1 $samples); do
13-
echo "REPORT_STACK" >/sys/kernel/debug/provoke-crash/DIRECT
27+
echo "REPORT_STACK" > $TRIGGER
1428
if [ -t 1 ]; then
1529
percent=$(( 100 * $i / $samples ))
1630
if [ "$percent" -ne "$report" ]; then

0 commit comments

Comments
 (0)