Skip to content

Commit c94811e

Browse files
PandiPanda69speed47
authored andcommitted
fix(inception): Zen1/2 results based on kernel mitigations
1 parent 3e67047 commit c94811e

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

spectre-meltdown-checker.sh

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,10 +2783,10 @@ write_msr_one_core()
27832783
# or fallback to dd if it supports seek_bytes, we prefer it over perl because we can tell the difference between EPERM and EIO
27842784
elif dd if=/dev/null of=/dev/null bs=8 count=1 seek="$_msr_dec" oflag=seek_bytes 2>/dev/null && [ "${SMC_NO_DD:-}" != 1 ]; then
27852785
_debug "write_msr: using dd"
2786-
awk "BEGIN{printf \"\%c\", $_value_dec}" | dd of=/dev/cpu/"$_core"/msr bs=8 count=1 seek="$_msr_dec" oflag=seek_bytes 2>/dev/null; ret=$?
2786+
awk "BEGIN{printf \"%c\", $_value_dec}" | dd of=/dev/cpu/"$_core"/msr bs=8 count=1 seek="$_msr_dec" oflag=seek_bytes 2>/dev/null; ret=$?
27872787
# if it failed, inspect stderrto look for EPERM
27882788
if [ "$ret" != 0 ]; then
2789-
if aws "BEGIN{printf \"%c\", $_value_dec}" | dd of=/dev/cpu/"$_core"/msr bs=8 count=1 seek="$_msr_dec" oflag=seek_bytes 2>&1 | grep -qF 'Operation not permitted'; then
2789+
if awk "BEGIN{printf \"%c\", $_value_dec}" | dd of=/dev/cpu/"$_core"/msr bs=8 count=1 seek="$_msr_dec" oflag=seek_bytes 2>&1 | grep -qF 'Operation not permitted'; then
27902790
_write_denied=1
27912791
fi
27922792
fi
@@ -6389,17 +6389,17 @@ check_CVE_2023_20569_linux() {
63896389

63906390
# Zen & Zen2 : if the right IBPB microcode applied + SMT off --> not vuln
63916391
if [ "$cpu_family" = $(( 0x17 )) ]; then
6392-
_info_nol " * IBPB support: "
6392+
_info_nol "* CPU supports IBPB : "
63936393
if [ -n "$cpuid_ibpb" ]; then
63946394
pstatus green YES "$cpuid_ibpb"
63956395
else
63966396
pstatus red NO
63976397
fi
63986398

6399-
_info_nol " * SMT is enabled: "
6399+
_info_nol "* SMT is enabled: "
64006400
is_cpu_smt_enabled; smt_enabled=$?
64016401
if [ "$smt_enabled" = 0 ]; then
6402-
pstatus red YES
6402+
pstatus yellow YES
64036403
else
64046404
pstatus green NO
64056405
fi
@@ -6424,20 +6424,13 @@ check_CVE_2023_20569_linux() {
64246424
if ! is_cpu_affected "$cve" ; then
64256425
# override status & msg in case CPU is not vulnerable after all
64266426
pvulnstatus "$cve" OK "your CPU vendor reported your CPU model as not affected"
6427-
elif [ "$cpu_family" = $(( 0x17 )) ]; then
6428-
if [ "$smt_enabled" = 1 ] && [ -n "$cpuid_ibpb" ]; then
6427+
elif [ -z "$msg" ]; then
6428+
# if msg is empty, sysfs check didn't fill it. If the kernel does not bring the mitigation.
6429+
if [ "$cpu_family" = $(( 0x17 )) ] && [ "$smt_enabled" = 1 ] && [ -n "$cpuid_ibpb" ]; then
64296430
pvulnstatus "$cve" OK "IBPB supported and SMT is off"
6430-
elif [ "$smt_enabled" != 1 ] && [ -n "$cpuid_ibpb" ]; then
6431-
pvulnstatus "$cve" VULN "SMT is enabled"
6432-
elif [ "$smt_enabled" = 1 ]; then
6433-
pvulnstatus "$cve" VULN "IBPB is not supported by your current microcode"
64346431
else
6435-
pvulnstatus "$cve" VULN "SMT is enabled and IBPB is not support by your current microcode"
6432+
pvulnstatus $cve VULN "upgrade your kernel"
64366433
fi
6437-
explain "Zen1/2 with SMT off aren't vulnerable after the right IBPB microcode has been applied. (https://github.com/torvalds/linux/commit/138bcddb86d8a4f842e4ed6f0585abc9b1a764ff#diff-17bd24a7a7850613cced545790ac30646097e8d6207348c2bd1845f397acb390R2272)"
6438-
elif [ -z "$msg" ]; then
6439-
# if msg is empty, sysfs check didn't fill it. If the kernel does not bring the mitigation, system vuln.
6440-
pvulnstatus $cve VULN "upgrade your kernel"
64416434
else
64426435
pvulnstatus $cve "$status" "$msg"
64436436
fi

0 commit comments

Comments
 (0)