2018-01-07 15:00:59 +01:00
|
|
|
#! /bin/sh
|
|
|
|
# Spectre & Meltdown checker
|
2018-01-09 09:21:42 +01:00
|
|
|
#
|
|
|
|
# Check for the latest version at:
|
|
|
|
# https://github.com/speed47/spectre-meltdown-checker
|
|
|
|
# git clone https://github.com/speed47/spectre-meltdown-checker.git
|
|
|
|
# or wget https://raw.githubusercontent.com/speed47/spectre-meltdown-checker/master/spectre-meltdown-checker.sh
|
|
|
|
#
|
2018-01-07 16:22:30 +01:00
|
|
|
# Stephane Lesimple
|
2018-01-09 09:21:42 +01:00
|
|
|
#
|
2018-01-14 22:34:09 +01:00
|
|
|
VERSION=0.31
|
2018-01-07 15:00:59 +01:00
|
|
|
|
2018-01-08 20:50:42 +01:00
|
|
|
show_usage()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
Usage:
|
2018-01-13 13:14:19 +01:00
|
|
|
Live mode: `basename $0` [options] [--live]
|
|
|
|
Offline mode: `basename $0` [options] [--kernel <vmlinux_file>] [--config <kernel_config>] [--map <kernel_map_file>]
|
2018-01-09 10:32:51 +01:00
|
|
|
|
|
|
|
Modes:
|
2018-01-08 20:50:42 +01:00
|
|
|
Two modes are available.
|
|
|
|
|
|
|
|
First mode is the "live" mode (default), it does its best to find information about the currently running kernel.
|
2018-01-12 11:46:36 +01:00
|
|
|
To run under this mode, just start the script without any option (you can also use --live explicitly)
|
2018-01-08 20:50:42 +01:00
|
|
|
|
|
|
|
Second mode is the "offline" mode, where you can inspect a non-running kernel.
|
2018-01-16 10:33:01 +01:00
|
|
|
You'll need to specify the location of the vmlinux file, config and System.map files:
|
2018-01-08 20:50:42 +01:00
|
|
|
|
|
|
|
--kernel vmlinux_file Specify a (possibly compressed) vmlinux file
|
|
|
|
--config kernel_config Specify a kernel config file
|
|
|
|
--map kernel_map_file Specify a kernel System.map file
|
|
|
|
|
2018-01-09 10:32:51 +01:00
|
|
|
Options:
|
|
|
|
--no-color Don't use color codes
|
2018-01-11 12:23:16 +01:00
|
|
|
--verbose, -v Increase verbosity level
|
|
|
|
--no-sysfs Don't use the /sys interface even if present
|
2018-01-16 10:33:01 +01:00
|
|
|
--coreos Special mode for CoreOS (use an ephemeral toolbox to inspect kernel)
|
2018-01-10 12:24:16 +01:00
|
|
|
--batch text Produce machine readable output, this is the default if --batch is specified alone
|
2018-01-11 09:04:13 +01:00
|
|
|
--batch json Produce JSON output formatted for Puppet, Ansible, Chef...
|
2018-01-10 12:59:33 +01:00
|
|
|
--batch nrpe Produce machine readable output formatted for NRPE
|
2018-01-10 12:24:16 +01:00
|
|
|
--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)
|
2018-01-09 10:32:51 +01:00
|
|
|
|
2018-01-16 10:33:01 +01:00
|
|
|
Return codes:
|
|
|
|
0 (not vulnerable), 2 (vulnerable), 3 (unknown), 255 (error)
|
2018-01-12 19:10:44 +01:00
|
|
|
|
2018-01-09 18:52:21 +01:00
|
|
|
IMPORTANT:
|
|
|
|
A false sense of security is worse than no security at all.
|
|
|
|
Please use the --disclaimer option to understand exactly what this script does.
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
show_disclaimer()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
Disclaimer:
|
|
|
|
|
|
|
|
This tool does its best to determine whether your system is immune (or has proper mitigations in place) for the
|
|
|
|
collectively named "speculative execution" vulnerabilities. It doesn't attempt to run any kind of exploit, and can't guarantee
|
|
|
|
that your system is secure, but rather helps you verifying whether your system has the known correct mitigations in place.
|
|
|
|
However, some mitigations could also exist in your kernel that this script doesn't know (yet) how to detect, or it might
|
|
|
|
falsely detect mitigations that in the end don't work as expected (for example, on backported or modified kernels).
|
|
|
|
|
|
|
|
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
|
2018-01-12 11:46:36 +01:00
|
|
|
explicitly stated otherwise in a verifiable public announcement.
|
2018-01-09 18:52:21 +01:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2018-01-08 20:50:42 +01:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2018-01-09 13:04:49 +01:00
|
|
|
# parse options
|
|
|
|
opt_kernel=''
|
|
|
|
opt_config=''
|
|
|
|
opt_map=''
|
|
|
|
opt_live_explicit=0
|
|
|
|
opt_live=1
|
|
|
|
opt_no_color=0
|
2018-01-09 13:37:26 +01:00
|
|
|
opt_batch=0
|
2018-01-10 12:57:45 +01:00
|
|
|
opt_batch_format="text"
|
2018-01-09 13:37:26 +01:00
|
|
|
opt_verbose=1
|
2018-01-10 12:24:16 +01:00
|
|
|
opt_variant1=0
|
|
|
|
opt_variant2=0
|
|
|
|
opt_variant3=0
|
|
|
|
opt_allvariants=1
|
2018-01-11 12:23:16 +01:00
|
|
|
opt_no_sysfs=0
|
2018-01-16 10:33:01 +01:00
|
|
|
opt_coreos=0
|
2018-01-10 12:57:45 +01:00
|
|
|
|
2018-01-13 20:33:12 +01:00
|
|
|
global_critical=0
|
|
|
|
global_unknown=0
|
2018-01-10 12:18:45 +01:00
|
|
|
nrpe_vuln=""
|
2018-01-09 13:04:49 +01:00
|
|
|
|
2018-01-18 11:00:40 +01:00
|
|
|
echo_cmd=''
|
2018-01-09 10:32:51 +01:00
|
|
|
__echo()
|
|
|
|
{
|
|
|
|
opt="$1"
|
|
|
|
shift
|
2018-01-11 12:23:16 +01:00
|
|
|
_msg="$@"
|
2018-01-18 11:00:40 +01:00
|
|
|
|
|
|
|
if [ -z "$echo_cmd" ]; then
|
|
|
|
# find a sane `echo` command
|
|
|
|
# we'll try to avoid using shell builtins that might not take options
|
|
|
|
if which echo >/dev/null 2>&1; then
|
|
|
|
echo_cmd=`which echo`
|
|
|
|
else
|
|
|
|
[ -x /bin/echo ] && echo_cmd=/bin/echo
|
|
|
|
[ -x /system/bin/echo ] && echo_cmd=/system/bin/echo
|
|
|
|
fi
|
|
|
|
# still empty ? fallback to builtin
|
|
|
|
[ -z "$echo_cmd" ] && echo_cmd=echo
|
|
|
|
fi
|
|
|
|
|
2018-01-09 10:32:51 +01:00
|
|
|
if [ "$opt_no_color" = 1 ] ; then
|
|
|
|
# strip ANSI color codes
|
2018-01-18 11:00:40 +01:00
|
|
|
_msg=$($echo_cmd -e "$_msg" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")
|
2018-01-09 10:32:51 +01:00
|
|
|
fi
|
2018-01-18 11:00:40 +01:00
|
|
|
$echo_cmd $opt -e "$_msg"
|
2018-01-09 10:32:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_echo()
|
|
|
|
{
|
2018-01-09 13:37:26 +01:00
|
|
|
if [ $opt_verbose -ge $1 ]; then
|
|
|
|
shift
|
|
|
|
__echo '' "$@"
|
|
|
|
fi
|
2018-01-09 10:32:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_echo_nol()
|
|
|
|
{
|
2018-01-09 13:37:26 +01:00
|
|
|
if [ $opt_verbose -ge $1 ]; then
|
|
|
|
shift
|
|
|
|
__echo -n "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_warn()
|
|
|
|
{
|
2018-01-11 09:55:43 +01:00
|
|
|
_echo 0 "\033[31m${@}\033[0m" >&2
|
2018-01-09 13:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_info()
|
|
|
|
{
|
|
|
|
_echo 1 "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
_info_nol()
|
|
|
|
{
|
|
|
|
_echo_nol 1 "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
_verbose()
|
|
|
|
{
|
|
|
|
_echo 2 "$@"
|
2018-01-09 10:32:51 +01:00
|
|
|
}
|
|
|
|
|
2018-01-14 15:44:11 +01:00
|
|
|
_verbose_nol()
|
|
|
|
{
|
|
|
|
_echo_nol 2 "$@"
|
|
|
|
}
|
|
|
|
|
2018-01-10 15:46:29 +01:00
|
|
|
_debug()
|
|
|
|
{
|
2018-01-12 10:53:19 +01:00
|
|
|
_echo 3 "\033[34m(debug) $@\033[0m"
|
2018-01-10 15:46:29 +01:00
|
|
|
}
|
|
|
|
|
2018-01-09 13:11:48 +01:00
|
|
|
is_cpu_vulnerable()
|
|
|
|
{
|
|
|
|
# param: 1, 2 or 3 (variant)
|
2018-01-13 13:16:37 +01:00
|
|
|
# returns 0 if vulnerable, 1 if not vulnerable
|
|
|
|
# (note that in shell, a return of 0 is success)
|
2018-01-09 14:54:17 +01:00
|
|
|
# by default, everything is vulnerable, we work in a "whitelist" logic here.
|
|
|
|
# usage: is_cpu_vulnerable 2 && do something if vulnerable
|
|
|
|
variant1=0
|
|
|
|
variant2=0
|
|
|
|
variant3=0
|
2018-01-15 14:12:49 +01:00
|
|
|
# we also set a friendly name for the CPU to be used in the script if needed
|
|
|
|
cpu_friendly_name=$(grep '^model name' /proc/cpuinfo | cut -d: -f2- | head -1)
|
2018-01-13 13:35:13 +01:00
|
|
|
|
2018-01-14 15:10:39 +01:00
|
|
|
if grep -q GenuineIntel /proc/cpuinfo; then
|
|
|
|
# Intel
|
|
|
|
# Old Atoms are not vulnerable to spectre 2 nor meltdown
|
|
|
|
# https://security-center.intel.com/advisory.aspx?intelid=INTEL-SA-00088&languageid=en-fr
|
2018-01-17 11:07:47 +01:00
|
|
|
# model name : Genuine Intel(R) CPU N270 @ 1.60GHz
|
2018-01-19 18:47:38 +01:00
|
|
|
# model name : Intel(R) Atom(TM) CPU N270 @ 1.60GHz
|
2018-01-17 11:07:47 +01:00
|
|
|
# model name : Intel(R) Atom(TM) CPU 330 @ 1.60GHz
|
2018-01-19 18:47:38 +01:00
|
|
|
if grep -qE '^model name.+ Intel\(R\) (Atom\(TM\) CPU +(S|D|N|230|330)|CPU N[0-9]{3} )' /proc/cpuinfo; then
|
2018-01-14 15:10:39 +01:00
|
|
|
variant2=1
|
|
|
|
variant3=1
|
|
|
|
fi
|
|
|
|
elif grep -q AuthenticAMD /proc/cpuinfo; then
|
2018-01-13 13:35:13 +01:00
|
|
|
# AMD revised their statement about variant2 => vulnerable
|
|
|
|
# https://www.amd.com/en/corporate/speculative-execution
|
2018-01-09 14:54:17 +01:00
|
|
|
variant3=1
|
2018-01-09 18:41:48 +01:00
|
|
|
elif grep -qi 'CPU implementer\s*:\s*0x41' /proc/cpuinfo; then
|
2018-01-09 13:11:48 +01:00
|
|
|
# ARM
|
|
|
|
# reference: https://developer.arm.com/support/security-update
|
2018-01-09 18:41:48 +01:00
|
|
|
cpupart=$(awk '/CPU part/ {print $4;exit}' /proc/cpuinfo)
|
|
|
|
cpuarch=$(awk '/CPU architecture/ {print $3;exit}' /proc/cpuinfo)
|
2018-01-15 23:45:25 +01:00
|
|
|
# some kernels report AArch64 instead of 8
|
|
|
|
[ "$cpuarch" = "AArch64" ] && cpuarch=8
|
2018-01-09 13:11:48 +01:00
|
|
|
if [ -n "$cpupart" -a -n "$cpuarch" ]; then
|
2018-01-15 23:45:25 +01:00
|
|
|
cpu_friendly_name="ARM v$cpuarch model $cpupart"
|
2018-01-09 13:11:48 +01:00
|
|
|
# Cortex-R7 and Cortex-R8 are real-time and only used in medical devices or such
|
|
|
|
# I can't find their CPU part number, but it's probably not that useful anyway
|
|
|
|
# model R7 R8 A9 A15 A17 A57 A72 A73 A75
|
|
|
|
# part ? ? 0xc09 0xc0f 0xc0e 0xd07 0xd08 0xd09 0xd0a
|
|
|
|
# arch 7? 7? 7 7 7 8 8 8 8
|
|
|
|
if [ "$cpuarch" = 7 ] && echo "$cpupart" | grep -Eq '^0x(c09|c0f|c0e)$'; then
|
|
|
|
# armv7 vulnerable chips
|
2018-01-13 13:16:37 +01:00
|
|
|
:
|
2018-01-09 13:11:48 +01:00
|
|
|
elif [ "$cpuarch" = 8 ] && echo "$cpupart" | grep -Eq '^0x(d07|d08|d09|d0a)$'; then
|
|
|
|
# armv8 vulnerable chips
|
2018-01-13 13:16:37 +01:00
|
|
|
:
|
2018-01-09 14:54:17 +01:00
|
|
|
else
|
2018-01-14 15:10:39 +01:00
|
|
|
# others are not vulnerable
|
2018-01-09 14:54:17 +01:00
|
|
|
variant1=1
|
|
|
|
variant2=1
|
2018-01-09 13:11:48 +01:00
|
|
|
fi
|
|
|
|
# for variant3, only A75 is vulnerable
|
2018-01-13 13:16:37 +01:00
|
|
|
if ! [ "$cpuarch" = 8 -a "$cpupart" = 0xd0a ]; then
|
2018-01-09 14:54:17 +01:00
|
|
|
variant3=1
|
2018-01-09 13:11:48 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2018-01-13 13:35:13 +01:00
|
|
|
|
2018-01-09 13:11:48 +01:00
|
|
|
[ "$1" = 1 ] && return $variant1
|
|
|
|
[ "$1" = 2 ] && return $variant2
|
|
|
|
[ "$1" = 3 ] && return $variant3
|
2018-01-13 13:16:37 +01:00
|
|
|
echo "$0: error: invalid variant '$1' passed to is_cpu_vulnerable()" >&2
|
2018-01-13 20:33:12 +01:00
|
|
|
exit 255
|
2018-01-09 13:11:48 +01:00
|
|
|
}
|
|
|
|
|
2018-01-09 13:37:26 +01:00
|
|
|
show_header()
|
|
|
|
{
|
|
|
|
_info "\033[1;34mSpectre and Meltdown mitigation detection tool v$VERSION\033[0m"
|
|
|
|
_info
|
|
|
|
}
|
2018-01-08 11:31:19 +01:00
|
|
|
|
2018-01-08 20:50:42 +01:00
|
|
|
parse_opt_file()
|
|
|
|
{
|
|
|
|
# parse_opt_file option_name option_value
|
|
|
|
option_name="$1"
|
|
|
|
option_value="$2"
|
|
|
|
if [ -z "$option_value" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
show_header
|
2018-01-08 20:50:42 +01:00
|
|
|
show_usage
|
|
|
|
echo "$0: error: --$option_name expects one parameter (a file)" >&2
|
|
|
|
exit 1
|
|
|
|
elif [ ! -e "$option_value" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
show_header
|
2018-01-08 20:50:42 +01:00
|
|
|
echo "$0: error: couldn't find file $option_value" >&2
|
|
|
|
exit 1
|
|
|
|
elif [ ! -f "$option_value" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
show_header
|
2018-01-08 20:50:42 +01:00
|
|
|
echo "$0: error: $option_value is not a file" >&2
|
|
|
|
exit 1
|
2018-01-10 21:17:14 +01:00
|
|
|
elif [ ! -r "$option_value" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
show_header
|
2018-01-08 20:50:42 +01:00
|
|
|
echo "$0: error: couldn't read $option_value (are you root?)" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "$option_value"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
while [ -n "$1" ]; do
|
|
|
|
if [ "$1" = "--kernel" ]; then
|
|
|
|
opt_kernel=$(parse_opt_file kernel "$2")
|
2018-01-13 20:33:12 +01:00
|
|
|
[ $? -ne 0 ] && exit 255
|
2018-01-08 20:50:42 +01:00
|
|
|
shift 2
|
|
|
|
opt_live=0
|
|
|
|
elif [ "$1" = "--config" ]; then
|
|
|
|
opt_config=$(parse_opt_file config "$2")
|
2018-01-13 20:33:12 +01:00
|
|
|
[ $? -ne 0 ] && exit 255
|
2018-01-08 20:50:42 +01:00
|
|
|
shift 2
|
|
|
|
opt_live=0
|
|
|
|
elif [ "$1" = "--map" ]; then
|
|
|
|
opt_map=$(parse_opt_file map "$2")
|
2018-01-13 20:33:12 +01:00
|
|
|
[ $? -ne 0 ] && exit 255
|
2018-01-08 20:50:42 +01:00
|
|
|
shift 2
|
|
|
|
opt_live=0
|
2018-01-09 10:32:51 +01:00
|
|
|
elif [ "$1" = "--live" ]; then
|
|
|
|
opt_live_explicit=1
|
|
|
|
shift
|
|
|
|
elif [ "$1" = "--no-color" ]; then
|
|
|
|
opt_no_color=1
|
|
|
|
shift
|
2018-01-11 12:23:16 +01:00
|
|
|
elif [ "$1" = "--no-sysfs" ]; then
|
|
|
|
opt_no_sysfs=1
|
|
|
|
shift
|
2018-01-16 10:33:01 +01:00
|
|
|
elif [ "$1" = "--coreos" ]; then
|
|
|
|
opt_coreos=1
|
|
|
|
shift
|
|
|
|
elif [ "$1" = "--coreos-within-toolbox" ]; then
|
|
|
|
# don't use directly: used internally by --coreos
|
|
|
|
opt_coreos=0
|
|
|
|
shift
|
2018-01-09 13:37:26 +01:00
|
|
|
elif [ "$1" = "--batch" ]; then
|
|
|
|
opt_batch=1
|
|
|
|
opt_verbose=0
|
|
|
|
shift
|
2018-01-10 12:57:45 +01:00
|
|
|
case "$1" in
|
2018-01-11 09:04:13 +01:00
|
|
|
text|nrpe|json) opt_batch_format="$1"; shift;;
|
2018-01-10 14:57:10 +01:00
|
|
|
--*) ;; # allow subsequent flags
|
|
|
|
'') ;; # allow nothing at all
|
|
|
|
*)
|
2018-01-13 20:33:12 +01:00
|
|
|
echo "$0: error: unknown batch format '$1'" >&2
|
|
|
|
echo "$0: error: --batch expects a format from: text, nrpe, json" >&2
|
|
|
|
exit 255
|
2018-01-10 14:57:10 +01:00
|
|
|
;;
|
2018-01-10 12:57:45 +01:00
|
|
|
esac
|
2018-01-09 13:37:26 +01:00
|
|
|
elif [ "$1" = "-v" -o "$1" = "--verbose" ]; then
|
|
|
|
opt_verbose=$(expr $opt_verbose + 1)
|
|
|
|
shift
|
2018-01-10 12:24:16 +01:00
|
|
|
elif [ "$1" = "--variant" ]; then
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
echo "$0: error: option --variant expects a parameter (1, 2 or 3)" >&2
|
2018-01-13 20:33:12 +01:00
|
|
|
exit 255
|
2018-01-10 12:24:16 +01:00
|
|
|
fi
|
|
|
|
case "$2" in
|
|
|
|
1) opt_variant1=1; opt_allvariants=0;;
|
|
|
|
2) opt_variant2=1; opt_allvariants=0;;
|
|
|
|
3) opt_variant3=1; opt_allvariants=0;;
|
|
|
|
*)
|
|
|
|
echo "$0: error: invalid parameter '$2' for --variant, expected either 1, 2 or 3" >&2;
|
2018-01-13 20:33:12 +01:00
|
|
|
exit 255
|
|
|
|
;;
|
2018-01-10 12:24:16 +01:00
|
|
|
esac
|
|
|
|
shift 2
|
2018-01-08 20:50:42 +01:00
|
|
|
elif [ "$1" = "-h" -o "$1" = "--help" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
show_header
|
2018-01-08 20:50:42 +01:00
|
|
|
show_usage
|
|
|
|
exit 0
|
2018-01-12 19:10:44 +01:00
|
|
|
elif [ "$1" = "--version" ]; then
|
|
|
|
opt_no_color=1
|
|
|
|
show_header
|
2018-01-13 20:33:12 +01:00
|
|
|
exit 0
|
2018-01-09 18:52:21 +01:00
|
|
|
elif [ "$1" = "--disclaimer" ]; then
|
|
|
|
show_header
|
|
|
|
show_disclaimer
|
|
|
|
exit 0
|
2018-01-08 20:50:42 +01:00
|
|
|
else
|
2018-01-09 13:37:26 +01:00
|
|
|
show_header
|
2018-01-08 20:50:42 +01:00
|
|
|
show_usage
|
|
|
|
echo "$0: error: unknown option '$1'"
|
2018-01-13 20:33:12 +01:00
|
|
|
exit 255
|
2018-01-08 20:50:42 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-01-09 13:37:26 +01:00
|
|
|
show_header
|
|
|
|
|
2018-01-09 13:04:49 +01:00
|
|
|
# print status function
|
|
|
|
pstatus()
|
|
|
|
{
|
|
|
|
if [ "$opt_no_color" = 1 ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
_info_nol "$2"
|
2018-01-09 13:04:49 +01:00
|
|
|
else
|
|
|
|
case "$1" in
|
|
|
|
red) col="\033[101m\033[30m";;
|
|
|
|
green) col="\033[102m\033[30m";;
|
|
|
|
yellow) col="\033[103m\033[30m";;
|
|
|
|
blue) col="\033[104m\033[30m";;
|
|
|
|
*) col="";;
|
|
|
|
esac
|
2018-01-09 13:37:26 +01:00
|
|
|
_info_nol "$col $2 \033[0m"
|
2018-01-09 13:04:49 +01:00
|
|
|
fi
|
2018-01-09 13:37:26 +01:00
|
|
|
[ -n "$3" ] && _info_nol " ($3)"
|
|
|
|
_info
|
2018-01-09 13:04:49 +01:00
|
|
|
}
|
|
|
|
|
2018-01-09 13:37:26 +01:00
|
|
|
# Print the final status of a vulnerability (incl. batch mode)
|
|
|
|
# Arguments are: CVE UNK/OK/VULN description
|
|
|
|
pvulnstatus()
|
|
|
|
{
|
2018-01-10 12:57:45 +01:00
|
|
|
if [ "$opt_batch" = 1 ]; then
|
2018-01-13 20:33:12 +01:00
|
|
|
case "$opt_batch_format" in
|
|
|
|
text) _echo 0 "$1: $2 ($3)";;
|
|
|
|
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
|
|
|
|
UNK) is_vuln="null";;
|
|
|
|
VULN) is_vuln="true";;
|
|
|
|
OK) is_vuln="false";;
|
|
|
|
esac
|
|
|
|
json_output="${json_output:-[}{\"NAME\":\""$aka"\",\"CVE\":\""$1"\",\"VULNERABLE\":$is_vuln,\"INFOS\":\""$3"\"},"
|
|
|
|
;;
|
|
|
|
|
|
|
|
nrpe) [ "$2" = VULN ] && nrpe_vuln="$nrpe_vuln $1";;
|
2018-01-10 12:18:45 +01:00
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2018-01-13 20:33:12 +01:00
|
|
|
# always fill global_* vars because we use that do decide the program exit code
|
|
|
|
case "$2" in
|
|
|
|
UNK) global_unknown="1";;
|
|
|
|
VULN) global_critical="1";;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# display info if we're not in quiet/batch mode
|
2018-01-14 15:47:22 +01:00
|
|
|
vulnstatus="$2"
|
|
|
|
shift 2
|
2018-01-09 13:37:26 +01:00
|
|
|
_info_nol "> \033[46m\033[30mSTATUS:\033[0m "
|
2018-01-14 15:47:22 +01:00
|
|
|
case "$vulnstatus" in
|
2018-01-13 20:33:12 +01:00
|
|
|
UNK) pstatus yellow 'UNKNOWN' "$@";;
|
|
|
|
VULN) pstatus red 'VULNERABLE' "$@";;
|
|
|
|
OK) pstatus green 'NOT VULNERABLE' "$@";;
|
2018-01-09 13:37:26 +01:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-09 13:04:49 +01:00
|
|
|
# The 3 below functions are taken from the extract-linux script, available here:
|
|
|
|
# https://github.com/torvalds/linux/blob/master/scripts/extract-vmlinux
|
|
|
|
# The functions have been modified for better integration to this script
|
|
|
|
# The original header of the file has been retained below
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# extract-vmlinux - Extract uncompressed vmlinux from a kernel image
|
|
|
|
#
|
|
|
|
# Inspired from extract-ikconfig
|
|
|
|
# (c) 2009,2010 Dick Streefland <dick@streefland.net>
|
|
|
|
#
|
|
|
|
# (c) 2011 Corentin Chary <corentin.chary@gmail.com>
|
|
|
|
#
|
|
|
|
# Licensed under the GNU General Public License, version 2 (GPLv2).
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
vmlinux=''
|
|
|
|
vmlinux_err=''
|
|
|
|
check_vmlinux()
|
|
|
|
{
|
2018-01-10 20:10:57 +01:00
|
|
|
readelf -h "$1" > /dev/null 2>&1 || return 1
|
2018-01-09 13:04:49 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
try_decompress()
|
|
|
|
{
|
|
|
|
# The obscure use of the "tr" filter is to work around older versions of
|
|
|
|
# "grep" that report the byte offset of the line instead of the pattern.
|
|
|
|
|
|
|
|
# Try to find the header ($1) and decompress from here
|
2018-01-10 20:10:57 +01:00
|
|
|
for pos in `tr "$1\n$2" "\n$2=" < "$6" | grep -abo "^$2"`
|
2018-01-09 13:04:49 +01:00
|
|
|
do
|
2018-01-10 20:10:57 +01:00
|
|
|
_debug "try_decompress: magic for $3 found at offset $pos"
|
|
|
|
if ! which "$3" >/dev/null 2>&1; then
|
|
|
|
vmlinux_err="missing '$3' tool, please install it, usually it's in the '$5' package"
|
2018-01-09 13:04:49 +01:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
pos=${pos%%:*}
|
2018-01-10 20:10:57 +01:00
|
|
|
tail -c+$pos "$6" 2>/dev/null | $3 $4 > $vmlinuxtmp 2>/dev/null
|
|
|
|
if check_vmlinux "$vmlinuxtmp"; then
|
|
|
|
vmlinux="$vmlinuxtmp"
|
|
|
|
_debug "try_decompress: decompressed with $3 successfully!"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
_debug "try_decompress: decompression with $3 did not work"
|
|
|
|
fi
|
2018-01-09 13:04:49 +01:00
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
extract_vmlinux()
|
|
|
|
{
|
|
|
|
[ -n "$1" ] || return 1
|
|
|
|
# Prepare temp files:
|
|
|
|
vmlinuxtmp="$(mktemp /tmp/vmlinux-XXXXXX)"
|
|
|
|
trap "rm -f $vmlinuxtmp" EXIT
|
|
|
|
|
|
|
|
# Initial attempt for uncompressed images or objects:
|
|
|
|
if check_vmlinux "$1"; then
|
|
|
|
cat "$1" > "$vmlinuxtmp"
|
|
|
|
vmlinux=$vmlinuxtmp
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# That didn't work, so retry after decompression.
|
2018-01-10 20:10:57 +01:00
|
|
|
try_decompress '\037\213\010' xy gunzip '' gunzip "$1" && return 0
|
|
|
|
try_decompress '\3757zXZ\000' abcde unxz '' xz-utils "$1" && return 0
|
|
|
|
try_decompress 'BZh' xy bunzip2 '' bzip2 "$1" && return 0
|
|
|
|
try_decompress '\135\0\0\0' xxx unlzma '' xz-utils "$1" && return 0
|
|
|
|
try_decompress '\211\114\132' xy 'lzop' '-d' lzop "$1" && return 0
|
|
|
|
try_decompress '\002\041\114\030' xyy 'lz4' '-d -l' liblz4-tool "$1" && return 0
|
2018-01-09 13:04:49 +01:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# end of extract-vmlinux functions
|
|
|
|
|
2018-01-16 10:33:01 +01:00
|
|
|
mount_debugfs()
|
|
|
|
{
|
|
|
|
if [ ! -e /sys/kernel/debug/sched_features ]; then
|
|
|
|
# try to mount the debugfs hierarchy ourselves and remember it to umount afterwards
|
|
|
|
mount -t debugfs debugfs /sys/kernel/debug 2>/dev/null && mounted_debugfs=1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
umount_debugfs()
|
|
|
|
{
|
|
|
|
if [ "$mounted_debugfs" = 1 ]; then
|
|
|
|
# umount debugfs if we did mount it ourselves
|
|
|
|
umount /sys/kernel/debug
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
load_msr()
|
|
|
|
{
|
|
|
|
modprobe msr 2>/dev/null && insmod_msr=1
|
|
|
|
_debug "attempted to load module msr, insmod_msr=$insmod_msr"
|
|
|
|
}
|
|
|
|
|
|
|
|
unload_msr()
|
|
|
|
{
|
|
|
|
if [ "$insmod_msr" = 1 ]; then
|
|
|
|
# if we used modprobe ourselves, rmmod the module
|
|
|
|
rmmod msr 2>/dev/null
|
|
|
|
_debug "attempted to unload module msr, ret=$?"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
load_cpuid()
|
|
|
|
{
|
|
|
|
modprobe cpuid 2>/dev/null && insmod_cpuid=1
|
|
|
|
_debug "attempted to load module cpuid, insmod_cpuid=$insmod_cpuid"
|
|
|
|
}
|
|
|
|
|
|
|
|
unload_cpuid()
|
|
|
|
{
|
|
|
|
if [ "$insmod_cpuid" = 1 ]; then
|
|
|
|
# if we used modprobe ourselves, rmmod the module
|
|
|
|
rmmod cpuid 2>/dev/null
|
|
|
|
_debug "attempted to unload module cpuid, ret=$?"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
is_coreos()
|
|
|
|
{
|
|
|
|
which coreos-install >/dev/null 2>&1 && which toolbox >/dev/null 2>&1 && return 0
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2018-01-09 10:32:51 +01:00
|
|
|
# check for mode selection inconsistency
|
|
|
|
if [ "$opt_live_explicit" = 1 ]; then
|
|
|
|
if [ -n "$opt_kernel" -o -n "$opt_config" -o -n "$opt_map" ]; then
|
|
|
|
show_usage
|
2018-01-13 20:33:12 +01:00
|
|
|
echo "$0: error: incompatible modes specified, use either --live or --kernel/--config/--map" >&2
|
|
|
|
exit 255
|
2018-01-09 10:32:51 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-01-16 10:33:01 +01:00
|
|
|
# coreos mode
|
|
|
|
if [ "$opt_coreos" = 1 ]; then
|
|
|
|
if ! is_coreos; then
|
|
|
|
_warn "CoreOS mode asked, but we're not under CoreOS!"
|
|
|
|
exit 255
|
|
|
|
fi
|
|
|
|
_warn "CoreOS mode, starting an ephemeral toolbox to launch the script"
|
|
|
|
load_msr
|
|
|
|
load_cpuid
|
|
|
|
mount_debugfs
|
2018-01-18 10:17:25 +01:00
|
|
|
toolbox --ephemeral --bind-ro /dev/cpu:/dev/cpu -- sh -c "dnf install -y binutils which && /media/root$PWD/$0 $@ --coreos-within-toolbox"
|
2018-01-16 10:33:01 +01:00
|
|
|
exitcode=$?
|
|
|
|
mount_debugfs
|
|
|
|
unload_cpuid
|
|
|
|
unload_msr
|
|
|
|
exit $exitcode
|
|
|
|
else
|
|
|
|
if is_coreos; then
|
|
|
|
_warn "You seem to be running CoreOS, you might want to use the --coreos option for better results"
|
|
|
|
_warn
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-01-08 20:50:42 +01:00
|
|
|
# root check (only for live mode, for offline mode, we already checked if we could read the files)
|
|
|
|
|
|
|
|
if [ "$opt_live" = 1 ]; then
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
_warn "Note that you should launch this script with root privileges to get accurate information."
|
|
|
|
_warn "We'll proceed but you might see permission denied errors."
|
|
|
|
_warn "To run it as root, you can try the following command: sudo $0"
|
|
|
|
_warn
|
2018-01-08 20:50:42 +01:00
|
|
|
fi
|
2018-01-12 19:07:23 +01:00
|
|
|
_info "Checking for vulnerabilities against running kernel \033[35m"$(uname -s) $(uname -r) $(uname -v) $(uname -m)"\033[0m"
|
2018-01-15 14:12:49 +01:00
|
|
|
# call is_cpu_vulnerable to fill the cpu_friendly_name var
|
|
|
|
is_cpu_vulnerable 1
|
2018-01-15 23:45:25 +01:00
|
|
|
_info "CPU is \033[35m$cpu_friendly_name\033[0m"
|
2018-01-08 20:50:42 +01:00
|
|
|
|
|
|
|
# try to find the image of the current running kernel
|
2018-01-10 15:46:29 +01:00
|
|
|
# first, look for the BOOT_IMAGE hint in the kernel cmdline
|
|
|
|
if [ -r /proc/cmdline ] && grep -q 'BOOT_IMAGE=' /proc/cmdline; then
|
|
|
|
opt_kernel=$(grep -Eo 'BOOT_IMAGE=[^ ]+' /proc/cmdline | cut -d= -f2)
|
|
|
|
_debug "found opt_kernel=$opt_kernel in /proc/cmdline"
|
|
|
|
# if we have a dedicated /boot partition, our bootloader might have just called it /
|
|
|
|
# so try to prepend /boot and see if we find anything
|
2018-01-10 16:27:16 +01:00
|
|
|
[ -e "/boot/$opt_kernel" ] && opt_kernel="/boot/$opt_kernel"
|
2018-01-16 10:33:01 +01:00
|
|
|
# special case for CoreOS if we're inside the toolbox
|
|
|
|
[ -e "/media/root/boot/$opt_kernel" ] && opt_kernel="/media/root/boot/$opt_kernel"
|
2018-01-10 15:46:29 +01:00
|
|
|
_debug "opt_kernel is now $opt_kernel"
|
|
|
|
# else, the full path is already there (most probably /boot/something)
|
|
|
|
fi
|
|
|
|
# if we didn't find a kernel, default to guessing
|
|
|
|
if [ ! -e "$opt_kernel" ]; then
|
2018-01-16 18:19:33 +01:00
|
|
|
# Fedora:
|
2018-01-19 12:35:16 +01:00
|
|
|
[ -e /lib/modules/$(uname -r)/vmlinuz ] && opt_kernel=/lib/modules/$(uname -r)/vmlinuz
|
2018-01-16 18:19:33 +01:00
|
|
|
# Slackare:
|
2018-01-16 10:58:00 +01:00
|
|
|
[ -e /boot/vmlinuz ] && opt_kernel=/boot/vmlinuz
|
2018-01-16 18:19:33 +01:00
|
|
|
# Arch:
|
2018-01-10 15:46:29 +01:00
|
|
|
[ -e /boot/vmlinuz-linux ] && opt_kernel=/boot/vmlinuz-linux
|
2018-01-16 18:19:33 +01:00
|
|
|
# Linux-Libre:
|
2018-01-10 15:46:29 +01:00
|
|
|
[ -e /boot/vmlinuz-linux-libre ] && opt_kernel=/boot/vmlinuz-linux-libre
|
2018-01-16 18:19:33 +01:00
|
|
|
# generic:
|
2018-01-10 15:46:29 +01:00
|
|
|
[ -e /boot/vmlinuz-$(uname -r) ] && opt_kernel=/boot/vmlinuz-$(uname -r)
|
|
|
|
[ -e /boot/kernel-$( uname -r) ] && opt_kernel=/boot/kernel-$( uname -r)
|
|
|
|
[ -e /boot/bzImage-$(uname -r) ] && opt_kernel=/boot/bzImage-$(uname -r)
|
2018-01-16 18:19:33 +01:00
|
|
|
# Gentoo:
|
2018-01-10 15:46:29 +01:00
|
|
|
[ -e /boot/kernel-genkernel-$(uname -m)-$(uname -r) ] && opt_kernel=/boot/kernel-genkernel-$(uname -m)-$(uname -r)
|
2018-01-16 18:19:33 +01:00
|
|
|
# NixOS:
|
2018-01-14 16:18:29 +01:00
|
|
|
[ -e /run/booted-system/kernel ] && opt_kernel=/run/booted-system/kernel
|
2018-01-10 15:46:29 +01:00
|
|
|
fi
|
2018-01-08 20:50:42 +01:00
|
|
|
|
|
|
|
# system.map
|
2018-01-09 08:58:09 +01:00
|
|
|
if [ -e /proc/kallsyms ] ; then
|
|
|
|
opt_map="/proc/kallsyms"
|
2018-01-19 12:35:16 +01:00
|
|
|
elif [ -e /lib/modules/$(uname -r)/System.map ] ; then
|
|
|
|
opt_map=/lib/modules/$(uname -r)/System.map
|
2018-01-09 08:58:09 +01:00
|
|
|
elif [ -e /boot/System.map-$(uname -r) ] ; then
|
|
|
|
opt_map=/boot/System.map-$(uname -r)
|
|
|
|
fi
|
2018-01-08 20:50:42 +01:00
|
|
|
|
|
|
|
# config
|
|
|
|
if [ -e /proc/config.gz ] ; then
|
2018-01-09 04:28:55 +01:00
|
|
|
dumped_config="$(mktemp /tmp/config-XXXXXX)"
|
2018-01-08 20:50:42 +01:00
|
|
|
gunzip -c /proc/config.gz > $dumped_config
|
|
|
|
# dumped_config will be deleted at the end of the script
|
|
|
|
opt_config=$dumped_config
|
2018-01-19 12:35:16 +01:00
|
|
|
elif [ -e /lib/modules/$(uname -r)/config ]; then
|
|
|
|
opt_config=/lib/modules/$(uname -r)/config
|
2018-01-08 20:50:42 +01:00
|
|
|
elif [ -e /boot/config-$(uname -r) ]; then
|
|
|
|
opt_config=/boot/config-$(uname -r)
|
|
|
|
fi
|
|
|
|
else
|
2018-01-09 13:37:26 +01:00
|
|
|
_info "Checking for vulnerabilities against specified kernel"
|
2018-01-08 20:50:42 +01:00
|
|
|
fi
|
2018-01-13 13:59:17 +01:00
|
|
|
|
2018-01-08 20:50:42 +01:00
|
|
|
if [ -n "$opt_kernel" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
_verbose "Will use vmlinux image \033[35m$opt_kernel\033[0m"
|
2018-01-08 20:50:42 +01:00
|
|
|
else
|
2018-01-09 13:37:26 +01:00
|
|
|
_verbose "Will use no vmlinux image (accuracy might be reduced)"
|
2018-01-13 13:59:17 +01:00
|
|
|
bad_accuracy=1
|
2018-01-08 20:50:42 +01:00
|
|
|
fi
|
2018-01-09 08:54:07 +01:00
|
|
|
if [ -n "$dumped_config" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
_verbose "Will use kconfig \033[35m/proc/config.gz\033[0m"
|
2018-01-09 08:54:07 +01:00
|
|
|
elif [ -n "$opt_config" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
_verbose "Will use kconfig \033[35m$opt_config\033[0m"
|
2018-01-08 20:50:42 +01:00
|
|
|
else
|
2018-01-09 13:37:26 +01:00
|
|
|
_verbose "Will use no kconfig (accuracy might be reduced)"
|
2018-01-13 13:59:17 +01:00
|
|
|
bad_accuracy=1
|
2018-01-08 20:50:42 +01:00
|
|
|
fi
|
|
|
|
if [ -n "$opt_map" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
_verbose "Will use System.map file \033[35m$opt_map\033[0m"
|
2018-01-08 20:50:42 +01:00
|
|
|
else
|
2018-01-09 13:37:26 +01:00
|
|
|
_verbose "Will use no System.map file (accuracy might be reduced)"
|
2018-01-13 13:59:17 +01:00
|
|
|
bad_accuracy=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$bad_accuracy" = 1 ]; then
|
|
|
|
_info "We're missing some kernel info (see -v), accuracy might be reduced"
|
2018-01-08 20:50:42 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e "$opt_kernel" ]; then
|
|
|
|
if ! which readelf >/dev/null 2>&1; then
|
2018-01-16 10:33:01 +01:00
|
|
|
_debug "readelf not found"
|
2018-01-08 20:50:42 +01:00
|
|
|
vmlinux_err="missing 'readelf' tool, please install it, usually it's in the 'binutils' package"
|
|
|
|
else
|
|
|
|
extract_vmlinux "$opt_kernel"
|
|
|
|
fi
|
|
|
|
else
|
2018-01-16 10:33:01 +01:00
|
|
|
_debug "no opt_kernel defined"
|
2018-01-09 18:44:15 +01:00
|
|
|
vmlinux_err="couldn't find your kernel image in /boot, if you used netboot, this is normal"
|
2018-01-08 20:50:42 +01:00
|
|
|
fi
|
|
|
|
if [ -z "$vmlinux" -o ! -r "$vmlinux" ]; then
|
|
|
|
[ -z "$vmlinux_err" ] && vmlinux_err="couldn't extract your kernel from $opt_kernel"
|
2018-01-08 11:31:19 +01:00
|
|
|
fi
|
|
|
|
|
2018-01-09 13:37:26 +01:00
|
|
|
_info
|
2018-01-08 12:14:12 +01:00
|
|
|
|
2018-01-10 12:24:16 +01:00
|
|
|
# end of header stuff
|
2018-01-07 16:16:11 +01:00
|
|
|
|
2018-01-10 12:24:16 +01:00
|
|
|
# now we define some util functions and the check_*() funcs, as
|
|
|
|
# the user can choose to execute only some of those
|
|
|
|
|
2018-01-11 12:23:16 +01:00
|
|
|
sys_interface_check()
|
|
|
|
{
|
|
|
|
[ "$opt_live" = 1 -a "$opt_no_sysfs" = 0 -a -r "$1" ] || return 1
|
2018-01-12 11:46:36 +01:00
|
|
|
_info_nol "* Checking whether we're safe according to the /sys interface: "
|
2018-01-11 12:23:16 +01:00
|
|
|
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")
|
2018-01-12 10:53:19 +01:00
|
|
|
_debug "sys_interface_check: $1=$msg"
|
2018-01-11 12:23:16 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2018-01-10 12:24:16 +01:00
|
|
|
###################
|
|
|
|
# SPECTRE VARIANT 1
|
|
|
|
check_variant1()
|
|
|
|
{
|
|
|
|
_info "\033[1;34mCVE-2017-5753 [bounds check bypass] aka 'Spectre Variant 1'\033[0m"
|
|
|
|
|
2018-01-11 12:23:16 +01:00
|
|
|
status=UNK
|
|
|
|
sys_interface_available=0
|
|
|
|
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
|
2018-01-07 16:16:11 +01:00
|
|
|
else
|
2018-01-11 12:23:16 +01:00
|
|
|
# no /sys interface (or offline mode), fallback to our own ways
|
|
|
|
_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
|
|