1
0
mirror of https://github.com/speed47/spectre-meltdown-checker synced 2024-11-06 22:23:41 +01:00

remove hardcoded kernel image path

This commit is contained in:
Stéphane Lesimple 2018-01-07 16:25:50 +01:00
parent 9ed1fcd98a
commit 30de4f6336

View File

@ -1,7 +1,7 @@
#! /bin/sh #! /bin/sh
# Spectre & Meltdown checker # Spectre & Meltdown checker
# Stephane Lesimple # Stephane Lesimple
VERSION=0.02 VERSION=0.03
pstatus() pstatus()
{ {
@ -73,22 +73,29 @@ extract_vmlinux()
/bin/echo -e "\033[1;34mCVE-2017-5753 [bounds check bypass] aka 'Spectre Variant 1'\033[0m" /bin/echo -e "\033[1;34mCVE-2017-5753 [bounds check bypass] aka 'Spectre Variant 1'\033[0m"
/bin/echo -n "* Kernel compiled with LFENCE opcode inserted at the proper places: " /bin/echo -n "* Kernel compiled with LFENCE opcode inserted at the proper places: "
vmlinux=$(extract_vmlinux /boot/vmlinuz-4.4.110) img=''
status=0 [ -e /boot/vmlinuz-$(uname -r) ] && img=/boot/vmlinuz-$(uname -r)
if [ -z "$vmlinux" -o ! -r "$vmlinux" ]; then [ -e /boot/vmlinux-$(uname -r) ] && img=/boot/vmlinux-$(uname -r)
pstatus yellow UNKNOWN "couldn't extract your kernel" [ -e /boot/bzImage-$(uname -r) ] && img=/boot/bzImage-$(uname -r)
elif ! which objdump >/dev/null 2>&1; then if [ -z "$img" ]; then
pstatus yellow UNKNOWN "missing 'objdump' tool, please install it, usually it's in the binutils package" pstatus yellow UNKNOWN "couldn't find your kernel image in /boot"
else else
nb_lfence=$(objdump -D "$vmlinux" | grep -wc lfence) vmlinux=$(extract_vmlinux $img)
if [ "$nb_lfence" -lt 60 ]; then if [ -z "$vmlinux" -o ! -r "$vmlinux" ]; then
pstatus red NO "only $nb_lfence opcodes found, should be >= 60" pstatus yellow UNKNOWN "couldn't extract your kernel"
status=1 elif ! which objdump >/dev/null 2>&1; then
pstatus yellow UNKNOWN "missing 'objdump' tool, please install it, usually it's in the binutils package"
else else
pstatus green YES "$nb_lfence opcodes found, which is >= 60" nb_lfence=$(objdump -D "$vmlinux" | grep -wc lfence)
status=2 if [ "$nb_lfence" -lt 60 ]; then
pstatus red NO "only $nb_lfence opcodes found, should be >= 60"
status=1
else
pstatus green YES "$nb_lfence opcodes found, which is >= 60"
status=2
fi
rm -f $vmlinux
fi fi
rm -f $vmlinux
fi fi
/bin/echo -ne "> \033[46m\033[30mSTATUS:\033[0m " /bin/echo -ne "> \033[46m\033[30mSTATUS:\033[0m "