Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/powerpc: Detect taint change in mitigation patching test

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

+4 -4
+4 -4
tools/testing/selftests/powerpc/security/mitigation-patching.sh
··· 36 36 37 37 tainted=$(cat /proc/sys/kernel/tainted) 38 38 if [[ "$tainted" -ne 0 ]]; then 39 - echo "Error: kernel already tainted!" >&2 40 - exit 1 39 + echo "Warning: kernel already tainted! ($tainted)" >&2 41 40 fi 42 41 43 42 mitigations="barrier_nospec stf_barrier count_cache_flush rfi_flush entry_flush uaccess_flush" ··· 67 68 echo "Waiting for timeout ..." 68 69 wait 69 70 71 + orig_tainted=$tainted 70 72 tainted=$(cat /proc/sys/kernel/tainted) 71 - if [[ "$tainted" -ne 0 ]]; then 72 - echo "Error: kernel became tainted!" >&2 73 + if [[ "$tainted" != "$orig_tainted" ]]; then 74 + echo "Error: kernel newly tainted, before ($orig_tainted) after ($tainted)" >&2 73 75 exit 1 74 76 fi 75 77