4 Commits
v0.06 ... v0.09

2 changed files with 34 additions and 18 deletions

View File

@ -28,7 +28,7 @@ Example of the output of the script:
```
$ sudo ./spectre-meltdown-checker.sh
Spectre and Meltdown mitigation detection tool v0.02
Spectre and Meltdown mitigation detection tool v0.07
CVE-2017-5753 [bounds check bypass] aka 'Spectre Variant 1'
* Kernel compiled with LFENCE opcode inserted at the proper places: NO (only 38 opcodes found, should be >= 60)
@ -41,8 +41,8 @@ CVE-2017-5715 [branch target injection] aka 'Spectre Variant 2'
* IBRS enabled for Kernel space: NO
* IBRS enabled for User space: NO
* Mitigation 2
* Kernel recompiled with retpolines: UNKNOWN (check not yet implemented)
> STATUS: VULNERABLE (IBRS hardware + kernel support OR retpolines-compiled kernel are needed to mitigate the vulnerability)
* Kernel compiled with retpolines: NO
> STATUS: VULNERABLE (IBRS hardware + kernel support OR kernel with retpolines are needed to mitigate the vulnerability)
CVE-2017-5754 [rogue data cache load] aka 'Meltdown' aka 'Variant 3'
* Kernel supports Page Table Isolation (PTI): YES

View File

@ -1,7 +1,7 @@
#! /bin/sh
# Spectre & Meltdown checker
# Stephane Lesimple
VERSION=0.06
VERSION=0.09
pstatus()
{
@ -43,7 +43,7 @@ try_decompress()
do
pos=${pos%%:*}
tail -c+$pos "$img" | $3 > $vmlinuxtmp 2> /dev/null
check_vmlinux $vmlinuxtmp && echo $vmlinuxtmp || rm -f $vmlinuxtmp
check_vmlinux $vmlinuxtmp && echo $vmlinuxtmp && return 0
done
}
@ -55,7 +55,11 @@ extract_vmlinux()
vmlinuxtmp=$(mktemp /tmp/vmlinux-XXX)
# Initial attempt for uncompressed images or objects:
check_vmlinux $img
if check_vmlinux $img; then
cat $img > $vmlinuxtmp
echo $vmlinuxtmp
return 0
fi
# That didn't work, so retry after decompression.
try_decompress '\037\213\010' xy gunzip || \
@ -77,6 +81,7 @@ status=0
img=''
[ -e /boot/vmlinuz-$(uname -r) ] && img=/boot/vmlinuz-$(uname -r)
[ -e /boot/vmlinux-$(uname -r) ] && img=/boot/vmlinux-$(uname -r)
[ -e /boot/kernel-$( uname -r) ] && img=/boot/kernel-$( uname -r)
[ -e /boot/bzImage-$(uname -r) ] && img=/boot/bzImage-$(uname -r)
if [ -z "$img" ]; then
pstatus yellow UNKNOWN "couldn't find your kernel image in /boot"
@ -95,7 +100,6 @@ else
pstatus green YES "$nb_lfence opcodes found, which is >= 60"
status=2
fi
rm -f $vmlinux
fi
fi
@ -178,6 +182,8 @@ elif [ -e /boot/config-$(uname -r) ]; then
else
pstatus red NO
fi
else
pstatus yellow UNKNOWN "couldn't read your kernel configuration"
fi
/bin/echo -ne "> \033[46m\033[30mSTATUS:\033[0m "
@ -216,15 +222,23 @@ elif [ -e /boot/System.map-$(uname -r) ]; then
else
pstatus red NO
fi
elif [ -n "$vmlinux" ]; then
# some backports don't have the option but still have the patch, try to find out
if strings "$vmlinux" | grep -qw nopti; then
pstatus green YES
kpti_support=1
else
pstatus red NO
fi
else
pstatus yellow UNKNOWN
pstatus yellow UNKNOWN "couldn't read your kernel configuration"
fi
/bin/echo -n "* PTI enabled and active: "
if grep ^flags /proc/cpuinfo | grep -qw pti; then
pstatus green YES
kpti_enabled=1
elif dmesg | grep -q 'Kernel/User page tables isolation: enabled'; then
elif dmesg | grep -Eq 'Kernel/User page tables isolation: enabled|Kernel page table isolation enabled'; then
pstatus green YES
kpti_enabled=1
else
@ -247,3 +261,5 @@ if [ "$USER" != root ]; then
/bin/echo "You can try the following command: sudo $0"
fi
[ -n "$vmlinux" -a -f "$vmlinux" ] && rm -f "$vmlinux"