Skip to content

Commit dbe208f

Browse files
committed
enh: downfall: detect kernel mitigation without sysfs
1 parent aca4e2a commit dbe208f

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

spectre-meltdown-checker.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6229,17 +6229,30 @@ check_CVE_2022_40982_linux() {
62296229
fi
62306230

62316231
if [ -n "$kernel_gds" ]; then
6232-
_info_nol "* Is the kernel mitigation active: "
6232+
_info_nol "* Kernel has disabled AVX as a mitigation: "
62336233

62346234
# Check dmesg message to see whether AVX has been disabled
6235-
dmesg_grep 'Microcode update needed! Disabling AVX as mitigation'; ret=$?
6236-
if [ $ret -eq 2 ]; then
6237-
pstatus yellow UNKNOWN "dmesg truncated, AVX mitigation detection will be unreliable. Please reboot and relaunch this script"
6238-
elif [ $ret -eq 0 ]; then
6239-
kernel_avx_disabled="AVX disabled by the kernel"
6235+
dmesg_grep 'Microcode update needed! Disabling AVX as mitigation'; dmesgret=$?
6236+
if [ $dmesgret -eq 0 ]; then
6237+
kernel_avx_disabled="AVX disabled by the kernel (dmesg)"
62406238
pstatus green YES "$kernel_avx_disabled"
6239+
elif [ "$has_avx2" = 0 ]; then
6240+
# Find out by ourselves
6241+
# cpuinfo says we don't have AVX2, query
6242+
# the CPU directly about AVX2 support
6243+
read_cpuid 0x7 0x0 $EBX 5 1 1; ret=$?
6244+
if [ $ret -eq $READ_CPUID_RET_OK ]; then
6245+
kernel_avx_disabled="AVX disabled by the kernel (cpuid)"
6246+
pstatus green YES "$kernel_avx_disabled"
6247+
elif [ $ret -eq $READ_CPUID_RET_KO ]; then
6248+
pstatus yellow NO "CPU doesn't support AVX"
6249+
elif [ $dmesgret -eq 2 ]; then
6250+
pstatus yellow UNKNOWN "dmesg truncated, can't tell whether mitigation is active, please reboot and relaunch this script"
6251+
else
6252+
pstatus yellow UNKNOWN "No sign of mitigation in dmesg and couldn't read cpuid info"
6253+
fi
62416254
else
6242-
pstatus red NO "No trace of AVX mitigation in dmesg"
6255+
pstatus yellow NO "AVX support is enabled"
62436256
fi
62446257
fi
62456258

0 commit comments

Comments
 (0)