mirror of
https://github.com/speed47/spectre-meltdown-checker.git
synced 2025-07-15 15:21:23 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
8c2fd0f0bb | |||
761c2b80e4 | |||
d6977928e5 | |||
bd4c74331e | |||
82972f8790 | |||
30de4f6336 |
@ -1,7 +1,7 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Spectre & Meltdown checker
|
# Spectre & Meltdown checker
|
||||||
# Stephane Lesimple
|
# Stephane Lesimple
|
||||||
VERSION=0.02
|
VERSION=0.05
|
||||||
|
|
||||||
pstatus()
|
pstatus()
|
||||||
{
|
{
|
||||||
@ -73,8 +73,15 @@ 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)
|
|
||||||
status=0
|
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/bzImage-$(uname -r) ] && img=/boot/bzImage-$(uname -r)
|
||||||
|
if [ -z "$img" ]; then
|
||||||
|
pstatus yellow UNKNOWN "couldn't find your kernel image in /boot"
|
||||||
|
else
|
||||||
|
vmlinux=$(extract_vmlinux $img)
|
||||||
if [ -z "$vmlinux" -o ! -r "$vmlinux" ]; then
|
if [ -z "$vmlinux" -o ! -r "$vmlinux" ]; then
|
||||||
pstatus yellow UNKNOWN "couldn't extract your kernel"
|
pstatus yellow UNKNOWN "couldn't extract your kernel"
|
||||||
elif ! which objdump >/dev/null 2>&1; then
|
elif ! which objdump >/dev/null 2>&1; then
|
||||||
@ -90,6 +97,7 @@ else
|
|||||||
fi
|
fi
|
||||||
rm -f $vmlinux
|
rm -f $vmlinux
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
/bin/echo -ne "> \033[46m\033[30mSTATUS:\033[0m "
|
/bin/echo -ne "> \033[46m\033[30mSTATUS:\033[0m "
|
||||||
[ "$status" = 0 ] && pstatus yellow UNKNOWN
|
[ "$status" = 0 ] && pstatus yellow UNKNOWN
|
||||||
@ -108,14 +116,23 @@ fi
|
|||||||
if [ ! -e /dev/cpu/0/msr ]; then
|
if [ ! -e /dev/cpu/0/msr ]; then
|
||||||
pstatus yellow UNKNOWN "couldn't read /dev/cpu/0/msr, is msr support enabled in your kernel?"
|
pstatus yellow UNKNOWN "couldn't read /dev/cpu/0/msr, is msr support enabled in your kernel?"
|
||||||
else
|
else
|
||||||
dd if=/dev/cpu/0/msr of=/dev/null bs=1 count=8 skip=72 2>/dev/null
|
if which rdmsr >/dev/null 2>&1; then
|
||||||
|
rdmsr 0x48 >/dev/null 2>&1
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
pstatus green YES
|
pstatus green YES
|
||||||
else
|
else
|
||||||
pstatus red NO
|
pstatus red NO
|
||||||
fi
|
fi
|
||||||
#dd if=/dev/cpu/0/msr of=/dev/null bs=1 count=8 skip=73 2>/dev/null
|
else
|
||||||
#/bin/echo $?
|
pstatus yellow UNKNOWN "missing 'rdmsr' tool, please install it, usually it's in the msr-tools package"
|
||||||
|
# doesn't work:
|
||||||
|
#dd if=/dev/cpu/0/msr of=/dev/null bs=1 count=8 skip=72 2>/dev/null
|
||||||
|
#if [ $? -eq 0 ]; then
|
||||||
|
# pstatus green YES
|
||||||
|
#else
|
||||||
|
# pstatus red NO
|
||||||
|
#fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$insmod_msr" = 1 ]; then
|
if [ "$insmod_msr" = 1 ]; then
|
||||||
@ -156,15 +173,32 @@ fi
|
|||||||
|
|
||||||
/bin/echo "* Mitigation 2"
|
/bin/echo "* Mitigation 2"
|
||||||
/bin/echo -n "* Kernel recompiled with retpolines: "
|
/bin/echo -n "* Kernel recompiled with retpolines: "
|
||||||
pstatus yellow UNKNOWN "check not yet implemented"
|
# XXX this doesn't mean the kernel has been compiled with a retpoline-aware gcc
|
||||||
|
if [ -e /proc/config.gz ]; then
|
||||||
|
if zgrep -q '^CONFIG_RETPOLINE=y' /proc/config.gz; then
|
||||||
|
pstatus green YES
|
||||||
|
retpoline=1
|
||||||
|
else
|
||||||
|
pstatus red NO
|
||||||
|
fi
|
||||||
|
elif [ -e /boot/config-$(uname -r) ]; then
|
||||||
|
if grep -q '^CONFIG_RETPOLINE=y' /boot/config-$(uname -r); then
|
||||||
|
pstatus green YES
|
||||||
|
retpoline=1
|
||||||
|
else
|
||||||
|
pstatus red NO
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
/bin/echo -ne "> \033[46m\033[30mSTATUS:\033[0m "
|
/bin/echo -ne "> \033[46m\033[30mSTATUS:\033[0m "
|
||||||
if grep -q AMD /proc/cpuinfo; then
|
if grep -q AMD /proc/cpuinfo; then
|
||||||
pstatus green "NOT VULNERABLE" "your CPU is not vulnerable as per the vendor"
|
pstatus green "NOT VULNERABLE" "your CPU is not vulnerable as per the vendor"
|
||||||
elif [ "$ibrs_enabled" = 1 -o "$ibrs_enabled" = 2 ]; then
|
elif [ "$ibrs_enabled" = 1 -o "$ibrs_enabled" = 2 ]; then
|
||||||
pstatus green "NOT VULNERABLE" "IBRS mitigates the vulnerability"
|
pstatus green "NOT VULNERABLE" "IBRS mitigates the vulnerability"
|
||||||
|
elif [ "$retpoline" = 1 ]; then
|
||||||
|
pstatus green "NOT VULNERABLE" "retpolines mitigate the vulnerability"
|
||||||
else
|
else
|
||||||
pstatus red VULNERABLE "IBRS hardware + kernel support OR retpolines-compiled kernel are needed to mitigate the vulnerability"
|
pstatus red VULNERABLE "IBRS hardware + kernel support OR kernel with retpolines are needed to mitigate the vulnerability"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# MELTDOWN
|
# MELTDOWN
|
||||||
|
Reference in New Issue
Block a user