detect kpti directly in vmlinux if option is not there

This commit is contained in:
Stéphane Lesimple 2018-01-07 22:47:41 +01:00
parent 9def0c949a
commit 05c79425ab
1 changed files with 12 additions and 3 deletions

View File

@ -1,7 +1,7 @@
#! /bin/sh #! /bin/sh
# Spectre & Meltdown checker # Spectre & Meltdown checker
# Stephane Lesimple # Stephane Lesimple
VERSION=0.07 VERSION=0.08
pstatus() pstatus()
{ {
@ -95,7 +95,6 @@ else
pstatus green YES "$nb_lfence opcodes found, which is >= 60" pstatus green YES "$nb_lfence opcodes found, which is >= 60"
status=2 status=2
fi fi
rm -f $vmlinux
fi fi
fi fi
@ -218,6 +217,14 @@ elif [ -e /boot/System.map-$(uname -r) ]; then
else else
pstatus red NO pstatus red NO
fi 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 else
pstatus yellow UNKNOWN "couldn't read your kernel configuration" pstatus yellow UNKNOWN "couldn't read your kernel configuration"
fi fi
@ -226,7 +233,7 @@ fi
if grep ^flags /proc/cpuinfo | grep -qw pti; then if grep ^flags /proc/cpuinfo | grep -qw pti; then
pstatus green YES pstatus green YES
kpti_enabled=1 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 pstatus green YES
kpti_enabled=1 kpti_enabled=1
else else
@ -249,3 +256,5 @@ if [ "$USER" != root ]; then
/bin/echo "You can try the following command: sudo $0" /bin/echo "You can try the following command: sudo $0"
fi fi
[ -n "$vmlinux" ] && rm -f "$vmlinux"