mirror of
https://github.com/speed47/spectre-meltdown-checker.git
synced 2025-07-15 15:21:23 +02:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
dce917bfbb | |||
8f18f53aba | |||
d3f102b3b3 | |||
8bd093173d | |||
bfe5a3b840 | |||
6a0242eea3 | |||
bc4e39038a | |||
62f8ed6f61 | |||
56b67f8082 | |||
52a8f78885 | |||
a09a5ba38f | |||
5a7d8d7edf | |||
49fdc6c449 | |||
af3de2a862 |
@ -3,7 +3,7 @@ Spectre & Meltdown Checker
|
|||||||
|
|
||||||
A simple shell script to tell if your Linux installation is vulnerable against the 3 "speculative execution" CVEs that were made public early 2018.
|
A simple shell script to tell if your Linux installation is vulnerable against the 3 "speculative execution" CVEs that were made public early 2018.
|
||||||
|
|
||||||
Without options, it'll inspect you currently running kernel.
|
Without options, it'll inspect your currently running kernel.
|
||||||
You can also specify a kernel image on the command line, if you'd like to inspect a kernel you're not running.
|
You can also specify a kernel image on the command line, if you'd like to inspect a kernel you're not running.
|
||||||
|
|
||||||
The script will do its best to detect mitigations, including backported non-vanilla patches, regardless of the advertised kernel version number.
|
The script will do its best to detect mitigations, including backported non-vanilla patches, regardless of the advertised kernel version number.
|
||||||
@ -40,6 +40,6 @@ However, some mitigations could also exist in your kernel that this script doesn
|
|||||||
|
|
||||||
Your system exposure also depends on your CPU. As of now, AMD and ARM processors are marked as immune to some or all of these vulnerabilities (except some specific ARM models). All Intel processors manufactured since circa 1995 are thought to be vulnerable. Whatever processor one uses, one might seek more information from the manufacturer of that processor and/or of the device in which it runs.
|
Your system exposure also depends on your CPU. As of now, AMD and ARM processors are marked as immune to some or all of these vulnerabilities (except some specific ARM models). All Intel processors manufactured since circa 1995 are thought to be vulnerable. Whatever processor one uses, one might seek more information from the manufacturer of that processor and/or of the device in which it runs.
|
||||||
|
|
||||||
The nature of the discovered vulnerabilities being quite new, the landscape of vulnerable processors can be expected to change over time, which is why this script makes the assumption that all CPUs are vulnerable, except if the manufacturer explicitely stated otherwise in a verifiable public announcement.
|
The nature of the discovered vulnerabilities being quite new, the landscape of vulnerable processors can be expected to change over time, which is why this script makes the assumption that all CPUs are vulnerable, except if the manufacturer explicitly stated otherwise in a verifiable public announcement.
|
||||||
|
|
||||||
This tool has been released in the hope that it'll be useful, but don't use it to jump to conclusions about your security.
|
This tool has been released in the hope that it'll be useful, but don't use it to jump to conclusions about your security.
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#
|
#
|
||||||
# Stephane Lesimple
|
# Stephane Lesimple
|
||||||
#
|
#
|
||||||
VERSION=0.24
|
VERSION=0.28
|
||||||
|
|
||||||
# Script configuration
|
# Script configuration
|
||||||
show_usage()
|
show_usage()
|
||||||
@ -22,7 +22,7 @@ show_usage()
|
|||||||
Two modes are available.
|
Two modes are available.
|
||||||
|
|
||||||
First mode is the "live" mode (default), it does its best to find information about the currently running kernel.
|
First mode is the "live" mode (default), it does its best to find information about the currently running kernel.
|
||||||
To run under this mode, just start the script without any option (you can also use --live explicitely)
|
To run under this mode, just start the script without any option (you can also use --live explicitly)
|
||||||
|
|
||||||
Second mode is the "offline" mode, where you can inspect a non-running kernel.
|
Second mode is the "offline" mode, where you can inspect a non-running kernel.
|
||||||
You'll need to specify the location of the vmlinux file, and if possible, the corresponding config and System.map files:
|
You'll need to specify the location of the vmlinux file, and if possible, the corresponding config and System.map files:
|
||||||
@ -33,12 +33,15 @@ show_usage()
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
--no-color Don't use color codes
|
--no-color Don't use color codes
|
||||||
-v, --verbose Increase verbosity level
|
--verbose, -v Increase verbosity level
|
||||||
|
--no-sysfs Don't use the /sys interface even if present
|
||||||
--batch text Produce machine readable output, this is the default if --batch is specified alone
|
--batch text Produce machine readable output, this is the default if --batch is specified alone
|
||||||
|
--batch json Produce JSON output formatted for Puppet, Ansible, Chef...
|
||||||
--batch nrpe Produce machine readable output formatted for NRPE
|
--batch nrpe Produce machine readable output formatted for NRPE
|
||||||
--variant [1,2,3] Specify which variant you'd like to check, by default all variants are checked
|
--variant [1,2,3] Specify which variant you'd like to check, by default all variants are checked
|
||||||
Can be specified multiple times (e.g. --variant 2 --variant 3)
|
Can be specified multiple times (e.g. --variant 2 --variant 3)
|
||||||
|
|
||||||
|
|
||||||
IMPORTANT:
|
IMPORTANT:
|
||||||
A false sense of security is worse than no security at all.
|
A false sense of security is worse than no security at all.
|
||||||
Please use the --disclaimer option to understand exactly what this script does.
|
Please use the --disclaimer option to understand exactly what this script does.
|
||||||
@ -64,7 +67,7 @@ in which it runs.
|
|||||||
|
|
||||||
The nature of the discovered vulnerabilities being quite new, the landscape of vulnerable processors can be expected
|
The nature of the discovered vulnerabilities being quite new, the landscape of vulnerable processors can be expected
|
||||||
to change over time, which is why this script makes the assumption that all CPUs are vulnerable, except if the manufacturer
|
to change over time, which is why this script makes the assumption that all CPUs are vulnerable, except if the manufacturer
|
||||||
explicitely stated otherwise in a verifiable public announcement.
|
explicitly stated otherwise in a verifiable public announcement.
|
||||||
|
|
||||||
This tool has been released in the hope that it'll be useful, but don't use it to jump to conclusions about your security.
|
This tool has been released in the hope that it'll be useful, but don't use it to jump to conclusions about your security.
|
||||||
|
|
||||||
@ -85,6 +88,7 @@ opt_variant1=0
|
|||||||
opt_variant2=0
|
opt_variant2=0
|
||||||
opt_variant3=0
|
opt_variant3=0
|
||||||
opt_allvariants=1
|
opt_allvariants=1
|
||||||
|
opt_no_sysfs=0
|
||||||
|
|
||||||
nrpe_critical=0
|
nrpe_critical=0
|
||||||
nrpe_unknown=0
|
nrpe_unknown=0
|
||||||
@ -94,13 +98,13 @@ __echo()
|
|||||||
{
|
{
|
||||||
opt="$1"
|
opt="$1"
|
||||||
shift
|
shift
|
||||||
msg="$@"
|
_msg="$@"
|
||||||
if [ "$opt_no_color" = 1 ] ; then
|
if [ "$opt_no_color" = 1 ] ; then
|
||||||
# strip ANSI color codes
|
# strip ANSI color codes
|
||||||
msg=$(/bin/echo -e "$msg" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")
|
_msg=$(/bin/echo -e "$_msg" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")
|
||||||
fi
|
fi
|
||||||
# explicitely call /bin/echo to avoid shell builtins that might not take options
|
# explicitely call /bin/echo to avoid shell builtins that might not take options
|
||||||
/bin/echo $opt -e "$msg"
|
/bin/echo $opt -e "$_msg"
|
||||||
}
|
}
|
||||||
|
|
||||||
_echo()
|
_echo()
|
||||||
@ -121,7 +125,7 @@ _echo_nol()
|
|||||||
|
|
||||||
_warn()
|
_warn()
|
||||||
{
|
{
|
||||||
_echo 0 "\033[31m${@}\033[0m"
|
_echo 0 "\033[31m${@}\033[0m" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
_info()
|
_info()
|
||||||
@ -141,7 +145,7 @@ _verbose()
|
|||||||
|
|
||||||
_debug()
|
_debug()
|
||||||
{
|
{
|
||||||
_echo 3 "(debug) $@"
|
_echo 3 "\033[34m(debug) $@\033[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
is_cpu_vulnerable()
|
is_cpu_vulnerable()
|
||||||
@ -218,7 +222,7 @@ parse_opt_file()
|
|||||||
show_header
|
show_header
|
||||||
echo "$0: error: $option_value is not a file" >&2
|
echo "$0: error: $option_value is not a file" >&2
|
||||||
exit 1
|
exit 1
|
||||||
elif [ ! -e "$option_value" ]; then
|
elif [ ! -r "$option_value" ]; then
|
||||||
show_header
|
show_header
|
||||||
echo "$0: error: couldn't read $option_value (are you root?)" >&2
|
echo "$0: error: couldn't read $option_value (are you root?)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -249,17 +253,20 @@ while [ -n "$1" ]; do
|
|||||||
elif [ "$1" = "--no-color" ]; then
|
elif [ "$1" = "--no-color" ]; then
|
||||||
opt_no_color=1
|
opt_no_color=1
|
||||||
shift
|
shift
|
||||||
|
elif [ "$1" = "--no-sysfs" ]; then
|
||||||
|
opt_no_sysfs=1
|
||||||
|
shift
|
||||||
elif [ "$1" = "--batch" ]; then
|
elif [ "$1" = "--batch" ]; then
|
||||||
opt_batch=1
|
opt_batch=1
|
||||||
opt_verbose=0
|
opt_verbose=0
|
||||||
shift
|
shift
|
||||||
case "$1" in
|
case "$1" in
|
||||||
text|nrpe) opt_batch_format="$1"; shift;;
|
text|nrpe|json) opt_batch_format="$1"; shift;;
|
||||||
--*) ;; # allow subsequent flags
|
--*) ;; # allow subsequent flags
|
||||||
'') ;; # allow nothing at all
|
'') ;; # allow nothing at all
|
||||||
*)
|
*)
|
||||||
echo "$0: error: unknown batch format '$1'"
|
echo "$0: error: unknown batch format '$1'"
|
||||||
echo "$0: error: --batch expects a format from: text, nrpe"
|
echo "$0: error: --batch expects a format from: text, nrpe, json"
|
||||||
exit 1 >&2
|
exit 1 >&2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -284,6 +291,10 @@ while [ -n "$1" ]; do
|
|||||||
show_header
|
show_header
|
||||||
show_usage
|
show_usage
|
||||||
exit 0
|
exit 0
|
||||||
|
elif [ "$1" = "--version" ]; then
|
||||||
|
opt_no_color=1
|
||||||
|
show_header
|
||||||
|
exit 1
|
||||||
elif [ "$1" = "--disclaimer" ]; then
|
elif [ "$1" = "--disclaimer" ]; then
|
||||||
show_header
|
show_header
|
||||||
show_disclaimer
|
show_disclaimer
|
||||||
@ -322,14 +333,27 @@ pstatus()
|
|||||||
pvulnstatus()
|
pvulnstatus()
|
||||||
{
|
{
|
||||||
if [ "$opt_batch" = 1 ]; then
|
if [ "$opt_batch" = 1 ]; then
|
||||||
case "$opt_batch_format" in
|
case "$opt_batch_format" in
|
||||||
text) _echo 0 "$1: $2 ($3)";;
|
text) _echo 0 "$1: $2 ($3)";;
|
||||||
nrpe)
|
nrpe)
|
||||||
case "$2" in
|
case "$2" in
|
||||||
UKN) nrpe_unknown="1";;
|
UKN) nrpe_unknown="1";;
|
||||||
VULN) nrpe_critical="1"; nrpe_vuln="$nrpe_vuln $1";;
|
VULN) nrpe_critical="1"; nrpe_vuln="$nrpe_vuln $1";;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
json)
|
||||||
|
case "$1" in
|
||||||
|
CVE-2017-5753) aka="SPECTRE VARIANT 1";;
|
||||||
|
CVE-2017-5715) aka="SPECTRE VARIANT 2";;
|
||||||
|
CVE-2017-5754) aka="MELTDOWN";;
|
||||||
|
esac
|
||||||
|
case "$2" in
|
||||||
|
UKN) is_vuln="unknown";;
|
||||||
|
VULN) is_vuln="true";;
|
||||||
|
OK) is_vuln="false";;
|
||||||
|
esac
|
||||||
|
json_output="${json_output:-[}{\"NAME\":\""$aka"\",\"CVE\":\""$1"\",\"VULNERABLE\":$is_vuln,\"INFOS\":\""$3"\"},"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -438,7 +462,8 @@ if [ "$opt_live" = 1 ]; then
|
|||||||
_warn "To run it as root, you can try the following command: sudo $0"
|
_warn "To run it as root, you can try the following command: sudo $0"
|
||||||
_warn
|
_warn
|
||||||
fi
|
fi
|
||||||
_info "Checking for vulnerabilities against live running kernel \033[35m"$(uname -s) $(uname -r) $(uname -v) $(uname -m)"\033[0m"
|
_info "Checking for vulnerabilities against running kernel \033[35m"$(uname -s) $(uname -r) $(uname -v) $(uname -m)"\033[0m"
|
||||||
|
_info "CPU is\033[35m"$(grep '^model name' /proc/cpuinfo | cut -d: -f2 | head -1)"\033[0m"
|
||||||
|
|
||||||
# try to find the image of the current running kernel
|
# try to find the image of the current running kernel
|
||||||
# first, look for the BOOT_IMAGE hint in the kernel cmdline
|
# first, look for the BOOT_IMAGE hint in the kernel cmdline
|
||||||
@ -534,46 +559,84 @@ umount_debugfs()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sys_interface_check()
|
||||||
|
{
|
||||||
|
[ "$opt_live" = 1 -a "$opt_no_sysfs" = 0 -a -r "$1" ] || return 1
|
||||||
|
_info_nol "* Checking whether we're safe according to the /sys interface: "
|
||||||
|
if grep -qi '^not affected' "$1"; then
|
||||||
|
# Not affected
|
||||||
|
status=OK
|
||||||
|
pstatus green YES "kernel confirms that your CPU is unaffected"
|
||||||
|
elif grep -qi '^mitigation' "$1"; then
|
||||||
|
# Mitigation: PTI
|
||||||
|
status=OK
|
||||||
|
pstatus green YES "kernel confirms that the mitigation is active"
|
||||||
|
elif grep -qi '^vulnerable' "$1"; then
|
||||||
|
# Vulnerable
|
||||||
|
status=VULN
|
||||||
|
pstatus red NO "kernel confirms your system is vulnerable"
|
||||||
|
else
|
||||||
|
status=UNK
|
||||||
|
pstatus yellow UNKNOWN "unknown value reported by kernel"
|
||||||
|
fi
|
||||||
|
msg=$(cat "$1")
|
||||||
|
_debug "sys_interface_check: $1=$msg"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# SPECTRE VARIANT 1
|
# SPECTRE VARIANT 1
|
||||||
check_variant1()
|
check_variant1()
|
||||||
{
|
{
|
||||||
_info "\033[1;34mCVE-2017-5753 [bounds check bypass] aka 'Spectre Variant 1'\033[0m"
|
_info "\033[1;34mCVE-2017-5753 [bounds check bypass] aka 'Spectre Variant 1'\033[0m"
|
||||||
_info_nol "* Checking count of LFENCE opcodes in kernel: "
|
|
||||||
|
|
||||||
status=0
|
status=UNK
|
||||||
if [ -n "$vmlinux_err" ]; then
|
sys_interface_available=0
|
||||||
pstatus yellow UNKNOWN "$vmlinux_err"
|
msg=''
|
||||||
|
if sys_interface_check "/sys/devices/system/cpu/vulnerabilities/spectre_v1"; then
|
||||||
|
# this kernel has the /sys interface, trust it over everything
|
||||||
|
sys_interface_available=1
|
||||||
else
|
else
|
||||||
if ! which objdump >/dev/null 2>&1; then
|
# no /sys interface (or offline mode), fallback to our own ways
|
||||||
pstatus yellow UNKNOWN "missing 'objdump' tool, please install it, usually it's in the binutils package"
|
_info_nol "* Checking count of LFENCE opcodes in kernel: "
|
||||||
|
if [ -n "$vmlinux_err" ]; then
|
||||||
|
msg="couldn't check ($vmlinux_err)"
|
||||||
|
status=UNK
|
||||||
|
pstatus yellow UNKNOWN
|
||||||
else
|
else
|
||||||
# here we disassemble the kernel and count the number of occurences of the LFENCE opcode
|
if ! which objdump >/dev/null 2>&1; then
|
||||||
# in non-patched kernels, this has been empirically determined as being around 40-50
|
msg="missing 'objdump' tool, please install it, usually it's in the binutils package"
|
||||||
# in patched kernels, this is more around 70-80, sometimes way higher (100+)
|
status=UNK
|
||||||
# v0.13: 68 found in a 3.10.23-xxxx-std-ipv6-64 (with lots of modules compiled-in directly), which doesn't have the LFENCE patches,
|
pstatus yellow UNKNOWN
|
||||||
# so let's push the threshold to 70.
|
|
||||||
# TODO LKML patch is starting to dump LFENCE in favor of the PAUSE opcode, we might need to check that (patch not stabilized yet)
|
|
||||||
nb_lfence=$(objdump -D "$vmlinux" | grep -wc lfence)
|
|
||||||
if [ "$nb_lfence" -lt 70 ]; then
|
|
||||||
pstatus red NO "only $nb_lfence opcodes found, should be >= 70"
|
|
||||||
status=1
|
|
||||||
else
|
else
|
||||||
pstatus green YES "$nb_lfence opcodes found, which is >= 70"
|
# here we disassemble the kernel and count the number of occurences of the LFENCE opcode
|
||||||
status=2
|
# in non-patched kernels, this has been empirically determined as being around 40-50
|
||||||
|
# in patched kernels, this is more around 70-80, sometimes way higher (100+)
|
||||||
|
# v0.13: 68 found in a 3.10.23-xxxx-std-ipv6-64 (with lots of modules compiled-in directly), which doesn't have the LFENCE patches,
|
||||||
|
# so let's push the threshold to 70.
|
||||||
|
nb_lfence=$(objdump -d "$vmlinux" | grep -wc lfence)
|
||||||
|
if [ "$nb_lfence" -lt 70 ]; then
|
||||||
|
msg="only $nb_lfence opcodes found, should be >= 70, heuristic to be improved when official patches become available"
|
||||||
|
status=VULN
|
||||||
|
pstatus red NO
|
||||||
|
else
|
||||||
|
msg="$nb_lfence opcodes found, which is >= 70, heuristic to be improved when official patches become available"
|
||||||
|
status=OK
|
||||||
|
pstatus green YES
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! is_cpu_vulnerable 1; then
|
# if we have the /sys interface, don't even check is_cpu_vulnerable ourselves, the kernel already does it
|
||||||
pvulnstatus CVE-2017-5753 OK "your CPU vendor reported your CPU model as not vulnerable"
|
if [ "$sys_interface_available" = 0 ] && ! is_cpu_vulnerable 1; then
|
||||||
else
|
# override status & msg in case CPU is not vulnerable after all
|
||||||
case "$status" in
|
msg="your CPU vendor reported your CPU model as not vulnerable"
|
||||||
0) pvulnstatus CVE-2017-5753 UNK "impossible to check ${vmlinux}";;
|
status=OK
|
||||||
1) pvulnstatus CVE-2017-5753 VULN 'heuristic to be improved when official patches become available';;
|
|
||||||
2) pvulnstatus CVE-2017-5753 OK 'heuristic to be improved when official patches become available';;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# report status
|
||||||
|
pvulnstatus CVE-2017-5753 "$status" "$msg"
|
||||||
}
|
}
|
||||||
|
|
||||||
###################
|
###################
|
||||||
@ -581,153 +644,176 @@ check_variant1()
|
|||||||
check_variant2()
|
check_variant2()
|
||||||
{
|
{
|
||||||
_info "\033[1;34mCVE-2017-5715 [branch target injection] aka 'Spectre Variant 2'\033[0m"
|
_info "\033[1;34mCVE-2017-5715 [branch target injection] aka 'Spectre Variant 2'\033[0m"
|
||||||
_info "* Mitigation 1"
|
|
||||||
_info_nol "* Hardware (CPU microcode) support for mitigation: "
|
status=UNK
|
||||||
if [ ! -e /dev/cpu/0/msr ]; then
|
sys_interface_available=0
|
||||||
# try to load the module ourselves (and remember it so we can rmmod it afterwards)
|
msg=''
|
||||||
modprobe msr 2>/dev/null && insmod_msr=1
|
if sys_interface_check "/sys/devices/system/cpu/vulnerabilities/spectre_v2"; then
|
||||||
fi
|
# this kernel has the /sys interface, trust it over everything
|
||||||
if [ ! -e /dev/cpu/0/msr ]; then
|
sys_interface_available=1
|
||||||
pstatus yellow UNKNOWN "couldn't read /dev/cpu/0/msr, is msr support enabled in your kernel?"
|
|
||||||
else
|
else
|
||||||
# the new MSR 'SPEC_CTRL' is at offset 0x48
|
_info "* Mitigation 1"
|
||||||
# here we use dd, it's the same as using 'rdmsr 0x48' but without needing the rdmsr tool
|
_info_nol "* Hardware (CPU microcode) support for mitigation: "
|
||||||
# if we get a read error, the MSR is not there
|
if [ ! -e /dev/cpu/0/msr ]; then
|
||||||
dd if=/dev/cpu/0/msr of=/dev/null bs=8 count=1 skip=9 2>/dev/null
|
# try to load the module ourselves (and remember it so we can rmmod it afterwards)
|
||||||
if [ $? -eq 0 ]; then
|
modprobe msr 2>/dev/null && insmod_msr=1
|
||||||
pstatus green YES
|
_debug "attempted to load module msr, ret=$insmod_msr"
|
||||||
else
|
|
||||||
pstatus red NO
|
|
||||||
fi
|
fi
|
||||||
fi
|
if [ ! -e /dev/cpu/0/msr ]; then
|
||||||
|
pstatus yellow UNKNOWN "couldn't read /dev/cpu/0/msr, is msr support enabled in your kernel?"
|
||||||
if [ "$insmod_msr" = 1 ]; then
|
else
|
||||||
# if we used modprobe ourselves, rmmod the module
|
# the new MSR 'SPEC_CTRL' is at offset 0x48
|
||||||
rmmod msr 2>/dev/null
|
# here we use dd, it's the same as using 'rdmsr 0x48' but without needing the rdmsr tool
|
||||||
fi
|
# if we get a read error, the MSR is not there
|
||||||
|
dd if=/dev/cpu/0/msr of=/dev/null bs=8 count=1 skip=9 2>/dev/null
|
||||||
_info_nol "* Kernel support for IBRS: "
|
if [ $? -eq 0 ]; then
|
||||||
if [ "$opt_live" = 1 ]; then
|
|
||||||
mount_debugfs
|
|
||||||
for ibrs_file in \
|
|
||||||
/sys/kernel/debug/ibrs_enabled \
|
|
||||||
/sys/kernel/debug/x86/ibrs_enabled \
|
|
||||||
/proc/sys/kernel/ibrs_enabled; do
|
|
||||||
if [ -e "$ibrs_file" ]; then
|
|
||||||
# if the file is there, we have IBRS compiled-in
|
|
||||||
# /sys/kernel/debug/ibrs_enabled: vanilla
|
|
||||||
# /sys/kernel/debug/x86/ibrs_enabled: RedHat (see https://access.redhat.com/articles/3311301)
|
|
||||||
# /proc/sys/kernel/ibrs_enabled: OpenSUSE tumbleweed
|
|
||||||
pstatus green YES
|
pstatus green YES
|
||||||
ibrs_supported=1
|
|
||||||
ibrs_enabled=$(cat "$ibrs_file" 2>/dev/null)
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if [ "$ibrs_supported" != 1 -a -n "$opt_map" ]; then
|
|
||||||
if grep -q spec_ctrl "$opt_map"; then
|
|
||||||
pstatus green YES
|
|
||||||
ibrs_supported=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ "$ibrs_supported" != 1 ]; then
|
|
||||||
pstatus red NO
|
|
||||||
fi
|
|
||||||
|
|
||||||
_info_nol "* IBRS enabled for Kernel space: "
|
|
||||||
if [ "$opt_live" = 1 ]; then
|
|
||||||
# 0 means disabled
|
|
||||||
# 1 is enabled only for kernel space
|
|
||||||
# 2 is enabled for kernel and user space
|
|
||||||
case "$ibrs_enabled" in
|
|
||||||
"") [ "$ibrs_supported" = 1 ] && pstatus yellow UNKNOWN || pstatus red NO;;
|
|
||||||
0) pstatus red NO;;
|
|
||||||
1 | 2) pstatus green YES;;
|
|
||||||
*) pstatus yellow UNKNOWN;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
pstatus blue N/A "not testable in offline mode"
|
|
||||||
fi
|
|
||||||
|
|
||||||
_info_nol "* IBRS enabled for User space: "
|
|
||||||
if [ "$opt_live" = 1 ]; then
|
|
||||||
case "$ibrs_enabled" in
|
|
||||||
"") [ "$ibrs_supported" = 1 ] && pstatus yellow UNKNOWN || pstatus red NO;;
|
|
||||||
0 | 1) pstatus red NO;;
|
|
||||||
2) pstatus green YES;;
|
|
||||||
*) pstatus yellow UNKNOWN;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
pstatus blue N/A "not testable in offline mode"
|
|
||||||
fi
|
|
||||||
|
|
||||||
_info "* Mitigation 2"
|
|
||||||
_info_nol "* Kernel compiled with retpoline option: "
|
|
||||||
# We check the RETPOLINE kernel options
|
|
||||||
if [ -r "$opt_config" ]; then
|
|
||||||
if grep -q '^CONFIG_RETPOLINE=y' "$opt_config"; then
|
|
||||||
pstatus green YES
|
|
||||||
retpoline=1
|
|
||||||
else
|
|
||||||
pstatus red NO
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
pstatus yellow UNKNOWN "couldn't read your kernel configuration"
|
|
||||||
fi
|
|
||||||
|
|
||||||
_info_nol "* Kernel compiled with a retpoline-aware compiler: "
|
|
||||||
# Now check if the compiler used to compile the kernel knows how to insert retpolines in generated asm
|
|
||||||
# For gcc, this is -mindirect-branch=thunk-extern (detected by the kernel makefiles)
|
|
||||||
# See gcc commit https://github.com/hjl-tools/gcc/commit/23b517d4a67c02d3ef80b6109218f2aadad7bd79
|
|
||||||
# In latest retpoline LKML patches, the noretpoline_setup symbol exists only if CONFIG_RETPOLINE is set
|
|
||||||
# *AND* if the compiler is retpoline-compliant, so look for that symbol
|
|
||||||
if [ -n "$opt_map" ]; then
|
|
||||||
# look for the symbol
|
|
||||||
if grep -qw noretpoline_setup "$opt_map"; then
|
|
||||||
retpoline_compiler=1
|
|
||||||
pstatus green YES "noretpoline_setup symbol found in System.map"
|
|
||||||
else
|
|
||||||
pstatus red NO
|
|
||||||
fi
|
|
||||||
elif [ -n "$vmlinux" ]; then
|
|
||||||
# look for the symbol
|
|
||||||
if which nm >/dev/null 2>&1; then
|
|
||||||
# the proper way: use nm and look for the symbol
|
|
||||||
if nm "$vmlinux" 2>/dev/null | grep -qw 'noretpoline_setup'; then
|
|
||||||
retpoline_compiler=1
|
|
||||||
pstatus green YES "noretpoline_setup found in vmlinux symbols"
|
|
||||||
else
|
else
|
||||||
pstatus red NO
|
pstatus red NO
|
||||||
fi
|
fi
|
||||||
elif grep -q noretpoline_setup "$vmlinux"; then
|
fi
|
||||||
# if we don't have nm, nevermind, the symbol name is long enough to not have
|
|
||||||
# any false positive using good old grep directly on the binary
|
if [ "$insmod_msr" = 1 ]; then
|
||||||
retpoline_compiler=1
|
# if we used modprobe ourselves, rmmod the module
|
||||||
pstatus green YES "noretpoline_setup found in vmlinux"
|
rmmod msr 2>/dev/null
|
||||||
else
|
_debug "attempted to unload module msr, ret=$?"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_info_nol "* Kernel support for IBRS: "
|
||||||
|
if [ "$opt_live" = 1 ]; then
|
||||||
|
mount_debugfs
|
||||||
|
for ibrs_file in \
|
||||||
|
/sys/kernel/debug/ibrs_enabled \
|
||||||
|
/sys/kernel/debug/x86/ibrs_enabled \
|
||||||
|
/proc/sys/kernel/ibrs_enabled; do
|
||||||
|
if [ -e "$ibrs_file" ]; then
|
||||||
|
# if the file is there, we have IBRS compiled-in
|
||||||
|
# /sys/kernel/debug/ibrs_enabled: vanilla
|
||||||
|
# /sys/kernel/debug/x86/ibrs_enabled: RedHat (see https://access.redhat.com/articles/3311301)
|
||||||
|
# /proc/sys/kernel/ibrs_enabled: OpenSUSE tumbleweed
|
||||||
|
pstatus green YES
|
||||||
|
ibrs_supported=1
|
||||||
|
ibrs_enabled=$(cat "$ibrs_file" 2>/dev/null)
|
||||||
|
_debug "ibrs: found $ibrs_file=$ibrs_enabled"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
_debug "ibrs: file $ibrs_file doesn't exist"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [ "$ibrs_supported" != 1 -a -n "$opt_map" ]; then
|
||||||
|
if grep -q spec_ctrl "$opt_map"; then
|
||||||
|
pstatus green YES
|
||||||
|
ibrs_supported=1
|
||||||
|
_debug "ibrs: found '*spec_ctrl*' symbol in $opt_map"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$ibrs_supported" != 1 ]; then
|
||||||
pstatus red NO
|
pstatus red NO
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
pstatus yellow UNKNOWN "couldn't find your kernel image or System.map"
|
_info_nol "* IBRS enabled for Kernel space: "
|
||||||
|
if [ "$opt_live" = 1 ]; then
|
||||||
|
# 0 means disabled
|
||||||
|
# 1 is enabled only for kernel space
|
||||||
|
# 2 is enabled for kernel and user space
|
||||||
|
case "$ibrs_enabled" in
|
||||||
|
"") [ "$ibrs_supported" = 1 ] && pstatus yellow UNKNOWN || pstatus red NO;;
|
||||||
|
0) pstatus red NO;;
|
||||||
|
1 | 2) pstatus green YES;;
|
||||||
|
*) pstatus yellow UNKNOWN;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
pstatus blue N/A "not testable in offline mode"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_info_nol "* IBRS enabled for User space: "
|
||||||
|
if [ "$opt_live" = 1 ]; then
|
||||||
|
case "$ibrs_enabled" in
|
||||||
|
"") [ "$ibrs_supported" = 1 ] && pstatus yellow UNKNOWN || pstatus red NO;;
|
||||||
|
0 | 1) pstatus red NO;;
|
||||||
|
2) pstatus green YES;;
|
||||||
|
*) pstatus yellow UNKNOWN;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
pstatus blue N/A "not testable in offline mode"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_info "* Mitigation 2"
|
||||||
|
_info_nol "* Kernel compiled with retpoline option: "
|
||||||
|
# We check the RETPOLINE kernel options
|
||||||
|
if [ -r "$opt_config" ]; then
|
||||||
|
if grep -q '^CONFIG_RETPOLINE=y' "$opt_config"; then
|
||||||
|
pstatus green YES
|
||||||
|
retpoline=1
|
||||||
|
_debug "retpoline: found "$(grep '^CONFIG_RETPOLINE' "$opt_config")" in $opt_config"
|
||||||
|
else
|
||||||
|
pstatus red NO
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
pstatus yellow UNKNOWN "couldn't read your kernel configuration"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_info_nol "* Kernel compiled with a retpoline-aware compiler: "
|
||||||
|
# Now check if the compiler used to compile the kernel knows how to insert retpolines in generated asm
|
||||||
|
# For gcc, this is -mindirect-branch=thunk-extern (detected by the kernel makefiles)
|
||||||
|
# See gcc commit https://github.com/hjl-tools/gcc/commit/23b517d4a67c02d3ef80b6109218f2aadad7bd79
|
||||||
|
# In latest retpoline LKML patches, the noretpoline_setup symbol exists only if CONFIG_RETPOLINE is set
|
||||||
|
# *AND* if the compiler is retpoline-compliant, so look for that symbol
|
||||||
|
if [ -n "$opt_map" ]; then
|
||||||
|
# look for the symbol
|
||||||
|
if grep -qw noretpoline_setup "$opt_map"; then
|
||||||
|
retpoline_compiler=1
|
||||||
|
pstatus green YES "noretpoline_setup symbol found in System.map"
|
||||||
|
else
|
||||||
|
pstatus red NO
|
||||||
|
fi
|
||||||
|
elif [ -n "$vmlinux" ]; then
|
||||||
|
# look for the symbol
|
||||||
|
if which nm >/dev/null 2>&1; then
|
||||||
|
# the proper way: use nm and look for the symbol
|
||||||
|
if nm "$vmlinux" 2>/dev/null | grep -qw 'noretpoline_setup'; then
|
||||||
|
retpoline_compiler=1
|
||||||
|
pstatus green YES "noretpoline_setup found in vmlinux symbols"
|
||||||
|
else
|
||||||
|
pstatus red NO
|
||||||
|
fi
|
||||||
|
elif grep -q noretpoline_setup "$vmlinux"; then
|
||||||
|
# if we don't have nm, nevermind, the symbol name is long enough to not have
|
||||||
|
# any false positive using good old grep directly on the binary
|
||||||
|
retpoline_compiler=1
|
||||||
|
pstatus green YES "noretpoline_setup found in vmlinux"
|
||||||
|
else
|
||||||
|
pstatus red NO
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
pstatus yellow UNKNOWN "couldn't find your kernel image or System.map"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! is_cpu_vulnerable 2; then
|
# if we have the /sys interface, don't even check is_cpu_vulnerable ourselves, the kernel already does it
|
||||||
|
if [ "$sys_interface_available" = 0 ] && ! is_cpu_vulnerable 2; then
|
||||||
|
# override status & msg in case CPU is not vulnerable after all
|
||||||
pvulnstatus CVE-2017-5715 OK "your CPU vendor reported your CPU model as not vulnerable"
|
pvulnstatus CVE-2017-5715 OK "your CPU vendor reported your CPU model as not vulnerable"
|
||||||
elif [ "$retpoline" = 1 -a "$retpoline_compiler" = 1 ]; then
|
elif [ -z "$msg" ]; then
|
||||||
pvulnstatus CVE-2017-5715 OK "retpoline mitigate the vulnerability"
|
# if msg is empty, sysfs check didn't fill it, rely on our own test
|
||||||
elif [ "$opt_live" = 1 ]; then
|
if [ "$retpoline" = 1 -a "$retpoline_compiler" = 1 ]; then
|
||||||
if [ "$ibrs_enabled" = 1 -o "$ibrs_enabled" = 2 ]; then
|
pvulnstatus CVE-2017-5715 OK "retpoline mitigate the vulnerability"
|
||||||
pvulnstatus CVE-2017-5715 OK "IBRS mitigates the vulnerability"
|
elif [ "$opt_live" = 1 ]; then
|
||||||
|
if [ "$ibrs_enabled" = 1 -o "$ibrs_enabled" = 2 ]; then
|
||||||
|
pvulnstatus CVE-2017-5715 OK "IBRS mitigates the vulnerability"
|
||||||
|
else
|
||||||
|
pvulnstatus CVE-2017-5715 VULN "IBRS hardware + kernel support OR kernel with retpoline are needed to mitigate the vulnerability"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
pvulnstatus CVE-2017-5715 VULN "IBRS hardware + kernel support OR kernel with retpoline are needed to mitigate the vulnerability"
|
if [ "$ibrs_supported" = 1 ]; then
|
||||||
|
pvulnstatus CVE-2017-5715 OK "offline mode: IBRS will mitigate the vulnerability if enabled at runtime"
|
||||||
|
else
|
||||||
|
pvulnstatus CVE-2017-5715 VULN "IBRS hardware + kernel support OR kernel with retpoline are needed to mitigate the vulnerability"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$ibrs_supported" = 1 ]; then
|
pvulnstatus CVE-2017-5715 "$status" "$msg"
|
||||||
pvulnstatus CVE-2017-5715 OK "offline mode: IBRS will mitigate the vulnerability if enabled at runtime"
|
|
||||||
else
|
|
||||||
pvulnstatus CVE-2017-5715 VULN "IBRS hardware + kernel support OR kernel with retpoline are needed to mitigate the vulnerability"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,88 +822,117 @@ check_variant2()
|
|||||||
check_variant3()
|
check_variant3()
|
||||||
{
|
{
|
||||||
_info "\033[1;34mCVE-2017-5754 [rogue data cache load] aka 'Meltdown' aka 'Variant 3'\033[0m"
|
_info "\033[1;34mCVE-2017-5754 [rogue data cache load] aka 'Meltdown' aka 'Variant 3'\033[0m"
|
||||||
_info_nol "* Kernel supports Page Table Isolation (PTI): "
|
|
||||||
kpti_support=0
|
status=UNK
|
||||||
kpti_can_tell=0
|
sys_interface_available=0
|
||||||
if [ -n "$opt_config" ]; then
|
msg=''
|
||||||
kpti_can_tell=1
|
if sys_interface_check "/sys/devices/system/cpu/vulnerabilities/meltdown"; then
|
||||||
if grep -Eq '^(CONFIG_PAGE_TABLE_ISOLATION|CONFIG_KAISER)=y' "$opt_config"; then
|
# this kernel has the /sys interface, trust it over everything
|
||||||
kpti_support=1
|
sys_interface_available=1
|
||||||
fi
|
else
|
||||||
fi
|
_info_nol "* Kernel supports Page Table Isolation (PTI): "
|
||||||
if [ "$kpti_support" = 0 -a -n "$opt_map" ]; then
|
kpti_support=0
|
||||||
# it's not an elif: some backports don't have the PTI config but still include the patch
|
kpti_can_tell=0
|
||||||
# so we try to find an exported symbol that is part of the PTI patch in System.map
|
if [ -n "$opt_config" ]; then
|
||||||
kpti_can_tell=1
|
kpti_can_tell=1
|
||||||
if grep -qw kpti_force_enabled "$opt_map"; then
|
if grep -Eq '^(CONFIG_PAGE_TABLE_ISOLATION|CONFIG_KAISER)=y' "$opt_config"; then
|
||||||
kpti_support=1
|
_debug "kpti_support: found option "$(grep -E '^(CONFIG_PAGE_TABLE_ISOLATION|CONFIG_KAISER)=y' "$opt_config")" in $opt_config"
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ "$kpti_support" = 0 -a -n "$vmlinux" ]; then
|
|
||||||
# same as above but in case we don't have System.map and only vmlinux, look for the
|
|
||||||
# nopti option that is part of the patch (kernel command line option)
|
|
||||||
kpti_can_tell=1
|
|
||||||
if ! which strings >/dev/null 2>&1; then
|
|
||||||
pstatus yellow UNKNOWN "missing 'strings' tool, please install it, usually it's in the binutils package"
|
|
||||||
else
|
|
||||||
if strings "$vmlinux" | grep -qw nopti; then
|
|
||||||
kpti_support=1
|
kpti_support=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
if [ "$kpti_support" = 0 -a -n "$opt_map" ]; then
|
||||||
|
# it's not an elif: some backports don't have the PTI config but still include the patch
|
||||||
if [ "$kpti_support" = 1 ]; then
|
# so we try to find an exported symbol that is part of the PTI patch in System.map
|
||||||
pstatus green YES
|
kpti_can_tell=1
|
||||||
elif [ "$kpti_can_tell" = 1 ]; then
|
if grep -qw kpti_force_enabled "$opt_map"; then
|
||||||
pstatus red NO
|
_debug "kpti_support: found kpti_force_enabled in $opt_map"
|
||||||
else
|
kpti_support=1
|
||||||
pstatus yellow UNKNOWN "couldn't read your kernel configuration nor System.map file"
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
mount_debugfs
|
|
||||||
_info_nol "* PTI enabled and active: "
|
|
||||||
if [ "$opt_live" = 1 ]; then
|
|
||||||
if grep ^flags /proc/cpuinfo | grep -qw pti; then
|
|
||||||
# vanilla PTI patch sets the 'pti' flag in cpuinfo
|
|
||||||
kpti_enabled=1
|
|
||||||
elif grep ^flags /proc/cpuinfo | grep -qw kaiser; then
|
|
||||||
# kernel line 4.9 sets the 'kaiser' flag in cpuinfo
|
|
||||||
kpti_enabled=1
|
|
||||||
elif [ -e /sys/kernel/debug/x86/pti_enabled ]; then
|
|
||||||
# RedHat Backport creates a dedicated file, see https://access.redhat.com/articles/3311301
|
|
||||||
kpti_enabled=$(cat /sys/kernel/debug/x86/pti_enabled 2>/dev/null)
|
|
||||||
elif dmesg | grep -Eq 'Kernel/User page tables isolation: enabled|Kernel page table isolation enabled'; then
|
|
||||||
# if we can't find the flag, grep dmesg output
|
|
||||||
kpti_enabled=1
|
|
||||||
elif [ -r /var/log/dmesg ] && grep -Eq 'Kernel/User page tables isolation: enabled|Kernel page table isolation enabled' /var/log/dmesg; then
|
|
||||||
# if we can't find the flag in dmesg output, grep in /var/log/dmesg when readable
|
|
||||||
kpti_enabled=1
|
|
||||||
else
|
|
||||||
kpti_enabled=0
|
|
||||||
fi
|
fi
|
||||||
if [ "$kpti_enabled" = 1 ]; then
|
if [ "$kpti_support" = 0 -a -n "$vmlinux" ]; then
|
||||||
pstatus green YES
|
# same as above but in case we don't have System.map and only vmlinux, look for the
|
||||||
else
|
# nopti option that is part of the patch (kernel command line option)
|
||||||
pstatus red NO
|
kpti_can_tell=1
|
||||||
|
if ! which strings >/dev/null 2>&1; then
|
||||||
|
pstatus yellow UNKNOWN "missing 'strings' tool, please install it, usually it's in the binutils package"
|
||||||
|
else
|
||||||
|
if strings "$vmlinux" | grep -qw nopti; then
|
||||||
|
_debug "kpti_support: found nopti string in $vmlinux"
|
||||||
|
kpti_support=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
pstatus blue N/A "can't verify if PTI is enabled in offline mode"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! is_cpu_vulnerable 3; then
|
|
||||||
pvulnstatus CVE-2017-5754 OK "your CPU vendor reported your CPU model as not vulnerable"
|
|
||||||
elif [ "$opt_live" = 1 ]; then
|
|
||||||
if [ "$kpti_enabled" = 1 ]; then
|
|
||||||
pvulnstatus CVE-2017-5754 OK "PTI mitigates the vulnerability"
|
|
||||||
else
|
|
||||||
pvulnstatus CVE-2017-5754 VULN "PTI is needed to mitigate the vulnerability"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ "$kpti_support" = 1 ]; then
|
if [ "$kpti_support" = 1 ]; then
|
||||||
pvulnstatus CVE-2017-5754 OK "offline mode: PTI will mitigate the vulnerability if enabled at runtime"
|
pstatus green YES
|
||||||
|
elif [ "$kpti_can_tell" = 1 ]; then
|
||||||
|
pstatus red NO
|
||||||
else
|
else
|
||||||
pvulnstatus CVE-2017-5754 VULN "PTI is needed to mitigate the vulnerability"
|
pstatus yellow UNKNOWN "couldn't read your kernel configuration nor System.map file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mount_debugfs
|
||||||
|
_info_nol "* PTI enabled and active: "
|
||||||
|
if [ "$opt_live" = 1 ]; then
|
||||||
|
dmesg_grep="Kernel/User page tables isolation: enabled"
|
||||||
|
dmesg_grep="$dmesg_grep|Kernel page table isolation enabled"
|
||||||
|
dmesg_grep="$dmesg_grep|x86/pti: Unmapping kernel while in userspace"
|
||||||
|
if grep ^flags /proc/cpuinfo | grep -qw pti; then
|
||||||
|
# vanilla PTI patch sets the 'pti' flag in cpuinfo
|
||||||
|
_debug "kpti_enabled: found 'pti' flag in /proc/cpuinfo"
|
||||||
|
kpti_enabled=1
|
||||||
|
elif grep ^flags /proc/cpuinfo | grep -qw kaiser; then
|
||||||
|
# kernel line 4.9 sets the 'kaiser' flag in cpuinfo
|
||||||
|
_debug "kpti_enabled: found 'kaiser' flag in /proc/cpuinfo"
|
||||||
|
kpti_enabled=1
|
||||||
|
elif [ -e /sys/kernel/debug/x86/pti_enabled ]; then
|
||||||
|
# RedHat Backport creates a dedicated file, see https://access.redhat.com/articles/3311301
|
||||||
|
kpti_enabled=$(cat /sys/kernel/debug/x86/pti_enabled 2>/dev/null)
|
||||||
|
_debug "kpti_enabled: file /sys/kernel/debug/x86/pti_enabled exists and says: $kpti_enabled"
|
||||||
|
elif dmesg | grep -Eq "$dmesg_grep"; then
|
||||||
|
# if we can't find the flag, grep dmesg output
|
||||||
|
_debug "kpti_enabled: found hint in dmesg: "$(dmesg | grep -E "$dmesg_grep")
|
||||||
|
kpti_enabled=1
|
||||||
|
elif [ -r /var/log/dmesg ] && grep -Eq "$dmesg_grep" /var/log/dmesg; then
|
||||||
|
# if we can't find the flag in dmesg output, grep in /var/log/dmesg when readable
|
||||||
|
_debug "kpti_enabled: found hint in /var/log/dmesg: "$(grep -E "$dmesg_grep" /var/log/dmesg)
|
||||||
|
kpti_enabled=1
|
||||||
|
else
|
||||||
|
_debug "kpti_enabled: couldn't find any hint that PTI is enabled"
|
||||||
|
kpti_enabled=0
|
||||||
|
fi
|
||||||
|
if [ "$kpti_enabled" = 1 ]; then
|
||||||
|
pstatus green YES
|
||||||
|
else
|
||||||
|
pstatus red NO
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
pstatus blue N/A "can't verify if PTI is enabled in offline mode"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if we have the /sys interface, don't even check is_cpu_vulnerable ourselves, the kernel already does it
|
||||||
|
cve='CVE-2017-5754'
|
||||||
|
if [ "$sys_interface_available" = 0 ] && ! is_cpu_vulnerable 3; then
|
||||||
|
# override status & msg in case CPU is not vulnerable after all
|
||||||
|
pvulnstatus $cve OK "your CPU vendor reported your CPU model as not vulnerable"
|
||||||
|
elif [ -z "$msg" ]; then
|
||||||
|
# if msg is empty, sysfs check didn't fill it, rely on our own test
|
||||||
|
if [ "$opt_live" = 1 ]; then
|
||||||
|
if [ "$kpti_enabled" = 1 ]; then
|
||||||
|
pvulnstatus $cve OK "PTI mitigates the vulnerability"
|
||||||
|
else
|
||||||
|
pvulnstatus $cve VULN "PTI is needed to mitigate the vulnerability"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$kpti_support" = 1 ]; then
|
||||||
|
pvulnstatus $cve OK "offline mode: PTI will mitigate the vulnerability if enabled at runtime"
|
||||||
|
else
|
||||||
|
pvulnstatus $cve VULN "PTI is needed to mitigate the vulnerability"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
pvulnstatus $cve "$status" "$msg"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,3 +968,7 @@ if [ "$opt_batch" = 1 -a "$opt_batch_format" = "nrpe" ]; then
|
|||||||
[ "$nrpe_unknown" = 1 ] && exit 3 # unknown
|
[ "$nrpe_unknown" = 1 ] && exit 3 # unknown
|
||||||
exit 0 # ok
|
exit 0 # ok
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$opt_batch" = 1 -a "$opt_batch_format" = "json" ]; then
|
||||||
|
_echo 0 ${json_output%?}]
|
||||||
|
fi
|
||||||
|
Reference in New Issue
Block a user