]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/powerpc: Detect taint change in mitigation patching test
authorMichael Ellerman <mpe@ellerman.id.au>
Wed, 6 Nov 2024 13:04:53 +0000 (00:04 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 7 Nov 2024 11:36:31 +0000 (22:36 +1100)
Currently the mitigation patching test errors out if the kernel is
tainted prior to the test running.

That causes the test to fail unnecessarily if some other test has caused
the kernel to be tainted, or if a proprietary or force module is loaded
for example.

Instead just warn if the kernel is tainted to begin with, and only
report a change in the taint state as an error in the test.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/20241106130453.1741013-5-mpe@ellerman.id.au
tools/testing/selftests/powerpc/security/mitigation-patching.sh

index f43aa4b77fbaa98a79326c3b35948c244a587730..9a4612e2e9537506c47358ed5315f34fd48e5601 100755 (executable)
@@ -36,8 +36,7 @@ fi
 
 tainted=$(cat /proc/sys/kernel/tainted)
 if [[ "$tainted" -ne 0 ]]; then
-    echo "Error: kernel already tainted!" >&2
-    exit 1
+    echo "Warning: kernel already tainted! ($tainted)" >&2
 fi
 
 mitigations="barrier_nospec stf_barrier count_cache_flush rfi_flush entry_flush uaccess_flush"
@@ -68,9 +67,10 @@ fi
 echo "Waiting for timeout ..."
 wait
 
+orig_tainted=$tainted
 tainted=$(cat /proc/sys/kernel/tainted)
-if [[ "$tainted" -ne 0 ]]; then
-    echo "Error: kernel became tainted!" >&2
+if [[ "$tainted" != "$orig_tainted" ]]; then
+    echo "Error: kernel newly tainted, before ($orig_tainted) after ($tainted)" >&2
     exit 1
 fi