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
|
2018-03-16 18:24:59 +01:00
|
|
|
# or wget https://meltdown.ovh -O spectre-meltdown-checker.sh
|
|
|
|
# or curl -L https://meltdown.ovh -o spectre-meltdown-checker.sh
|
2018-01-09 09:21:42 +01:00
|
|
|
#
|
2018-01-07 16:22:30 +01:00
|
|
|
# Stephane Lesimple
|
2018-01-09 09:21:42 +01:00
|
|
|
#
|
2018-04-01 17:45:01 +02:00
|
|
|
VERSION='0.36+'
|
2018-01-07 15:00:59 +01:00
|
|
|
|
2018-02-02 11:09:36 +01:00
|
|
|
trap 'exit_cleanup' EXIT
|
|
|
|
trap '_warn "interrupted, cleaning up..."; exit_cleanup; exit 1' INT
|
|
|
|
exit_cleanup()
|
|
|
|
{
|
|
|
|
# cleanup the temp decompressed config & kernel image
|
|
|
|
[ -n "$dumped_config" ] && [ -f "$dumped_config" ] && rm -f "$dumped_config"
|
2018-04-01 17:29:12 +02:00
|
|
|
[ -n "$kerneltmp" ] && [ -f "$kerneltmp" ] && rm -f "$kerneltmp"
|
|
|
|
[ -n "$kerneltmp2" ] && [ -f "$kerneltmp2" ] && rm -f "$kerneltmp2"
|
2018-02-02 11:09:36 +01:00
|
|
|
[ "$mounted_debugfs" = 1 ] && umount /sys/kernel/debug 2>/dev/null
|
2018-03-25 12:23:46 +02:00
|
|
|
[ "$mounted_procfs" = 1 ] && umount "$procfs" 2>/dev/null
|
2018-02-02 11:09:36 +01:00
|
|
|
[ "$insmod_cpuid" = 1 ] && rmmod cpuid 2>/dev/null
|
|
|
|
[ "$insmod_msr" = 1 ] && rmmod msr 2>/dev/null
|
2018-03-25 12:23:46 +02:00
|
|
|
[ "$kldload_cpuctl" = 1 ] && kldunload cpuctl 2>/dev/null
|
2018-02-02 11:09:36 +01:00
|
|
|
}
|
|
|
|
|
2018-01-08 20:50:42 +01:00
|
|
|
show_usage()
|
|
|
|
{
|
2018-01-29 10:29:48 +01:00
|
|
|
# shellcheck disable=SC2086
|
2018-01-08 20:50:42 +01:00
|
|
|
cat <<EOF
|
|
|
|
Usage:
|
2018-01-29 10:29:48 +01:00
|
|
|
Live mode: $(basename $0) [options] [--live]
|
2018-04-01 17:29:12 +02:00
|
|
|
Offline mode: $(basename $0) [options] [--kernel <kernel_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-04-01 17:29:12 +02:00
|
|
|
You'll need to specify the location of the kernel file, config and System.map files:
|
2018-01-08 20:50:42 +01:00
|
|
|
|
2018-03-25 12:27:40 +02:00
|
|
|
--kernel kernel_file specify a (possibly compressed) Linux or BSD kernel file
|
|
|
|
--config kernel_config specify a kernel config file (Linux only)
|
|
|
|
--map kernel_map_file specify a kernel System.map file (Linux only)
|
2018-01-08 20:50:42 +01:00
|
|
|
|
2018-01-09 10:32:51 +01:00
|
|
|
Options:
|
2018-03-25 12:27:40 +02:00
|
|
|
--no-color don't use color codes
|
|
|
|
--verbose, -v increase verbosity level, possibly several times
|
|
|
|
|
|
|
|
--no-sysfs don't use the /sys interface even if present [Linux]
|
|
|
|
--sysfs-only only use the /sys interface, don't run our own checks [Linux]
|
|
|
|
--coreos special mode for CoreOS (use an ephemeral toolbox to inspect kernel) [Linux]
|
|
|
|
|
|
|
|
--arch-prefix PREFIX specify a prefix for cross-inspecting a kernel of a different arch, for example "aarch64-linux-gnu-",
|
|
|
|
so that invoked tools will be prefixed with this (i.e. aarch64-linux-gnu-objdump)
|
|
|
|
--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 prometheus produce output for consumption by prometheus-node-exporter
|
|
|
|
|
|
|
|
--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-03-25 12:48:37 +02:00
|
|
|
--hw-only only check for CPU informations, don't check for any variant
|
2018-04-03 19:34:24 +02:00
|
|
|
--no-hw skip CPU information and checks, if you're inspecting a kernel not to be run on this host
|
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
|
2018-01-30 14:33:30 +01:00
|
|
|
vulnerabilities (except some specific ARM models). All Intel processors manufactured since circa 1995 are thought to be vulnerable,
|
|
|
|
except some specific/old models, such as some early Atoms. Whatever processor one uses, one might seek more information
|
|
|
|
from the manufacturer of that processor and/or of the device in which it runs.
|
2018-01-09 18:52:21 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
2018-01-30 14:33:30 +01:00
|
|
|
Please also note that for Spectre vulnerabilities, all software can possibly be exploited, this tool only verifies that the
|
|
|
|
kernel (which is the core of the system) you're using has the proper protections in place. Verifying all the other software
|
|
|
|
is out of the scope of this tool. As a general measure, ensure you always have the most up to date stable versions of all
|
|
|
|
the softwares you use, especially for those who are exposed to the world, such as network daemons and browsers.
|
|
|
|
|
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-03-25 12:23:46 +02:00
|
|
|
os=$(uname -s)
|
|
|
|
|
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-21 18:02:11 +01:00
|
|
|
opt_sysfs_only=0
|
2018-01-16 10:33:01 +01:00
|
|
|
opt_coreos=0
|
2018-03-17 13:17:10 +01:00
|
|
|
opt_arch_prefix=''
|
2018-03-25 12:48:37 +02:00
|
|
|
opt_hw_only=0
|
2018-04-03 19:34:24 +02:00
|
|
|
opt_no_hw=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-03-25 12:23:46 +02:00
|
|
|
# find a sane command to print colored messages, we prefer `printf` over `echo`
|
|
|
|
# because `printf` behavior is more standard across Linux/BSD
|
2018-01-24 17:55:36 +01:00
|
|
|
# we'll try to avoid using shell builtins that might not take options
|
2018-03-25 12:23:46 +02:00
|
|
|
echo_cmd_type=echo
|
|
|
|
if which printf >/dev/null 2>&1; then
|
|
|
|
echo_cmd=$(which printf)
|
|
|
|
echo_cmd_type=printf
|
|
|
|
elif which echo >/dev/null 2>&1; then
|
2018-01-29 10:29:48 +01:00
|
|
|
echo_cmd=$(which echo)
|
2018-01-24 17:55:36 +01:00
|
|
|
else
|
2018-03-25 12:23:46 +02:00
|
|
|
# which command is broken?
|
2018-01-24 17:55:36 +01:00
|
|
|
[ -x /bin/echo ] && echo_cmd=/bin/echo
|
2018-03-25 12:23:46 +02:00
|
|
|
# for Android
|
2018-01-24 17:55:36 +01:00
|
|
|
[ -x /system/bin/echo ] && echo_cmd=/system/bin/echo
|
|
|
|
fi
|
|
|
|
# still empty ? fallback to builtin
|
|
|
|
[ -z "$echo_cmd" ] && echo_cmd=echo
|
2018-01-09 10:32:51 +01:00
|
|
|
__echo()
|
|
|
|
{
|
|
|
|
opt="$1"
|
|
|
|
shift
|
2018-01-29 10:29:48 +01:00
|
|
|
_msg="$*"
|
2018-01-18 11:00:40 +01:00
|
|
|
|
2018-01-09 10:32:51 +01:00
|
|
|
if [ "$opt_no_color" = 1 ] ; then
|
|
|
|
# strip ANSI color codes
|
2018-02-02 10:59:49 +01:00
|
|
|
# some sed versions (i.e. toybox) can't seem to handle
|
|
|
|
# \033 aka \x1B correctly, so do it for them.
|
2018-03-25 12:23:46 +02:00
|
|
|
if [ "$echo_cmd_type" = printf ]; then
|
|
|
|
_interpret_chars=''
|
|
|
|
else
|
|
|
|
_interpret_chars='-e'
|
|
|
|
fi
|
|
|
|
_ctrlchar=$($echo_cmd $_interpret_chars "\033")
|
|
|
|
_msg=$($echo_cmd $_interpret_chars "$_msg" | sed -r "s/$_ctrlchar\[([0-9][0-9]?(;[0-9][0-9]?)?)?m//g")
|
|
|
|
fi
|
|
|
|
if [ "$echo_cmd_type" = printf ]; then
|
|
|
|
if [ "$opt" = "-n" ]; then
|
|
|
|
$echo_cmd "$_msg"
|
|
|
|
else
|
|
|
|
$echo_cmd "$_msg\n"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
$echo_cmd $opt -e "$_msg"
|
2018-01-09 10:32:51 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_echo()
|
|
|
|
{
|
2018-01-29 10:29:48 +01:00
|
|
|
if [ "$opt_verbose" -ge "$1" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
shift
|
2018-01-29 10:29:48 +01:00
|
|
|
__echo '' "$*"
|
2018-01-09 13:37:26 +01:00
|
|
|
fi
|
2018-01-09 10:32:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_echo_nol()
|
|
|
|
{
|
2018-01-29 10:29:48 +01:00
|
|
|
if [ "$opt_verbose" -ge "$1" ]; then
|
2018-01-09 13:37:26 +01:00
|
|
|
shift
|
2018-01-29 10:29:48 +01:00
|
|
|
__echo -n "$*"
|
2018-01-09 13:37:26 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_warn()
|
|
|
|
{
|
2018-01-29 10:29:48 +01:00
|
|
|
_echo 0 "\033[31m$*\033[0m" >&2
|
2018-01-09 13:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_info()
|
|
|
|
{
|
2018-01-29 10:29:48 +01:00
|
|
|
_echo 1 "$*"
|
2018-01-09 13:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_info_nol()
|
|
|
|
{
|
2018-01-29 10:29:48 +01:00
|
|
|
_echo_nol 1 "$*"
|
2018-01-09 13:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_verbose()
|
|
|
|
{
|
2018-01-29 10:29:48 +01:00
|
|
|
_echo 2 "$*"
|
2018-01-09 10:32:51 +01:00
|
|
|
}
|
|
|
|
|
2018-01-14 15:44:11 +01:00
|
|
|
_verbose_nol()
|
|
|
|
{
|
2018-01-29 10:29:48 +01:00
|
|
|
_echo_nol 2 "$*"
|
2018-01-14 15:44:11 +01:00
|
|
|
}
|
|
|
|
|
2018-01-10 15:46:29 +01:00
|
|
|
_debug()
|
|
|
|
{
|
2018-01-29 10:29:48 +01:00
|
|
|
_echo 3 "\033[34m(debug) $*\033[0m"
|
2018-01-10 15:46:29 +01:00
|
|
|
}
|
|
|
|
|
2018-01-18 21:16:14 +01:00
|
|
|
is_cpu_vulnerable_cached=0
|
|
|
|
_is_cpu_vulnerable_cached()
|
|
|
|
{
|
2018-01-29 10:29:48 +01:00
|
|
|
# shellcheck disable=SC2086
|
2018-01-18 21:16:14 +01:00
|
|
|
[ "$1" = 1 ] && return $variant1
|
2018-01-29 10:29:48 +01:00
|
|
|
# shellcheck disable=SC2086
|
2018-01-18 21:16:14 +01:00
|
|
|
[ "$1" = 2 ] && return $variant2
|
2018-01-29 10:29:48 +01:00
|
|
|
# shellcheck disable=SC2086
|
2018-01-18 21:16:14 +01:00
|
|
|
[ "$1" = 3 ] && return $variant3
|
|
|
|
echo "$0: error: invalid variant '$1' passed to is_cpu_vulnerable()" >&2
|
|
|
|
exit 255
|
|
|
|
}
|
|
|
|
|
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
|
2018-01-18 21:16:14 +01:00
|
|
|
if [ "$is_cpu_vulnerable_cached" = 1 ]; then
|
|
|
|
_is_cpu_vulnerable_cached "$1"
|
|
|
|
return $?
|
|
|
|
fi
|
|
|
|
|
2018-01-18 18:50:19 +01:00
|
|
|
variant1=''
|
|
|
|
variant2=''
|
|
|
|
variant3=''
|
2018-01-13 13:35:13 +01:00
|
|
|
|
2018-01-31 14:21:29 +01:00
|
|
|
if is_cpu_specex_free; then
|
|
|
|
variant1=immune
|
|
|
|
variant2=immune
|
|
|
|
variant3=immune
|
|
|
|
elif [ "$cpu_vendor" = GenuineIntel ]; then
|
2018-01-14 15:10:39 +01:00
|
|
|
# Intel
|
2018-01-29 11:18:15 +01:00
|
|
|
# https://github.com/crozone/SpectrePoC/issues/1 ^F E5200 => spectre 2 not vulnerable
|
|
|
|
# https://github.com/paboldin/meltdown-exploit/issues/19 ^F E5200 => meltdown vulnerable
|
|
|
|
# model name : Pentium(R) Dual-Core CPU E5200 @ 2.50GHz
|
2018-03-25 12:23:46 +02:00
|
|
|
if grep -qE '^model name.+ Pentium\(R\) Dual-Core[[:space:]]+CPU[[:space:]]+E[0-9]{4}K? ' "$procfs/cpuinfo"; then
|
2018-01-29 11:18:15 +01:00
|
|
|
variant1=vuln
|
|
|
|
[ -z "$variant2" ] && variant2=immune
|
|
|
|
variant3=vuln
|
2018-01-14 15:10:39 +01:00
|
|
|
fi
|
2018-01-24 14:44:16 +01:00
|
|
|
if [ "$capabilities_rdcl_no" = 1 ]; then
|
|
|
|
# capability bit for future Intel processor that will explicitly state
|
|
|
|
# that they're not vulnerable to Meltdown
|
|
|
|
# this var is set in check_cpu()
|
2018-01-29 11:18:15 +01:00
|
|
|
variant3=immune
|
2018-01-24 14:44:16 +01:00
|
|
|
_debug "is_cpu_vulnerable: RDCL_NO is set so not vuln to meltdown"
|
|
|
|
fi
|
2018-01-31 13:00:58 +01:00
|
|
|
elif [ "$cpu_vendor" = AuthenticAMD ]; 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-18 18:50:19 +01:00
|
|
|
variant1=vuln
|
|
|
|
variant2=vuln
|
|
|
|
[ -z "$variant3" ] && variant3=immune
|
2018-01-31 13:00:58 +01:00
|
|
|
elif [ "$cpu_vendor" = ARM ]; then
|
2018-01-09 13:11:48 +01:00
|
|
|
# ARM
|
|
|
|
# reference: https://developer.arm.com/support/security-update
|
2018-01-18 18:50:19 +01:00
|
|
|
# some devices (phones or other) have several ARMs and as such different part numbers,
|
|
|
|
# an example is "bigLITTLE". we shouldn't rely on the first CPU only, so we check the whole list
|
|
|
|
i=0
|
2018-01-31 13:00:58 +01:00
|
|
|
for cpupart in $cpu_part_list
|
2018-01-18 18:50:19 +01:00
|
|
|
do
|
|
|
|
i=$(( i + 1 ))
|
2018-02-02 11:00:23 +01:00
|
|
|
# do NOT quote $cpu_arch_list below
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
cpuarch=$(echo $cpu_arch_list | awk '{ print $'$i' }')
|
2018-01-18 18:50:19 +01:00
|
|
|
_debug "checking cpu$i: <$cpupart> <$cpuarch>"
|
|
|
|
# some kernels report AArch64 instead of 8
|
|
|
|
[ "$cpuarch" = "AArch64" ] && cpuarch=8
|
2018-01-29 10:29:48 +01:00
|
|
|
if [ -n "$cpupart" ] && [ -n "$cpuarch" ]; then
|
2018-01-18 18:50:19 +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
|
|
|
|
#
|
|
|
|
# variant 1 & variant 2
|
|
|
|
if [ "$cpuarch" = 7 ] && echo "$cpupart" | grep -Eq '^0x(c09|c0f|c0e)$'; then
|
|
|
|
# armv7 vulnerable chips
|
|
|
|
_debug "checking cpu$i: this armv7 vulnerable to spectre 1 & 2"
|
|
|
|
variant1=vuln
|
|
|
|
variant2=vuln
|
|
|
|
elif [ "$cpuarch" = 8 ] && echo "$cpupart" | grep -Eq '^0x(d07|d08|d09|d0a)$'; then
|
|
|
|
# armv8 vulnerable chips
|
|
|
|
_debug "checking cpu$i: this armv8 vulnerable to spectre 1 & 2"
|
|
|
|
variant1=vuln
|
|
|
|
variant2=vuln
|
|
|
|
else
|
|
|
|
_debug "checking cpu$i: this arm non vulnerable to 1 & 2"
|
|
|
|
# others are not vulnerable
|
|
|
|
[ -z "$variant1" ] && variant1=immune
|
|
|
|
[ -z "$variant2" ] && variant2=immune
|
|
|
|
fi
|
|
|
|
|
|
|
|
# for variant3, only A75 is vulnerable
|
2018-01-29 10:29:48 +01:00
|
|
|
if [ "$cpuarch" = 8 ] && [ "$cpupart" = 0xd0a ]; then
|
2018-01-18 18:50:19 +01:00
|
|
|
_debug "checking cpu$i: arm A75 vulnerable to meltdown"
|
|
|
|
variant3=vuln
|
|
|
|
else
|
|
|
|
_debug "checking cpu$i: this arm non vulnerable to meltdown"
|
|
|
|
[ -z "$variant3" ] && variant3=immune
|
|
|
|
fi
|
2018-01-09 13:11:48 +01:00
|
|
|
fi
|
2018-01-18 18:50:19 +01:00
|
|
|
_debug "is_cpu_vulnerable: for cpu$i and so far, we have <$variant1> <$variant2> <$variant3>"
|
|
|
|
done
|
2018-01-09 13:11:48 +01:00
|
|
|
fi
|
2018-01-18 18:50:19 +01:00
|
|
|
_debug "is_cpu_vulnerable: temp results are <$variant1> <$variant2> <$variant3>"
|
|
|
|
# if at least one of the cpu is vulnerable, then the system is vulnerable
|
|
|
|
[ "$variant1" = "immune" ] && variant1=1 || variant1=0
|
|
|
|
[ "$variant2" = "immune" ] && variant2=1 || variant2=0
|
|
|
|
[ "$variant3" = "immune" ] && variant3=1 || variant3=0
|
|
|
|
_debug "is_cpu_vulnerable: final results are <$variant1> <$variant2> <$variant3>"
|
2018-01-18 21:16:14 +01:00
|
|
|
is_cpu_vulnerable_cached=1
|
|
|
|
_is_cpu_vulnerable_cached "$1"
|
|
|
|
return $?
|
2018-01-09 13:11:48 +01:00
|
|
|
}
|
|
|
|
|
2018-01-31 14:21:29 +01:00
|
|
|
is_cpu_specex_free()
|
|
|
|
{
|
|
|
|
# return true (0) if the CPU doesn't do speculative execution, false (1) if it does.
|
|
|
|
# if it's not in the list we know, return false (1).
|
|
|
|
# source: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/cpu/common.c#n882
|
|
|
|
# { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CEDARVIEW, X86_FEATURE_ANY },
|
|
|
|
# { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CLOVERVIEW, X86_FEATURE_ANY },
|
|
|
|
# { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_LINCROFT, X86_FEATURE_ANY },
|
|
|
|
# { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PENWELL, X86_FEATURE_ANY },
|
|
|
|
# { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PINEVIEW, X86_FEATURE_ANY },
|
|
|
|
# { X86_VENDOR_CENTAUR, 5 },
|
|
|
|
# { X86_VENDOR_INTEL, 5 },
|
|
|
|
# { X86_VENDOR_NSC, 5 },
|
|
|
|
# { X86_VENDOR_ANY, 4 },
|
2018-02-02 11:10:36 +01:00
|
|
|
parse_cpu_details
|
2018-01-31 14:21:29 +01:00
|
|
|
if [ "$cpu_vendor" = GenuineIntel ]; then
|
|
|
|
if [ "$cpu_family" = 6 ]; then
|
|
|
|
if [ "$cpu_model" = "$INTEL_FAM6_ATOM_CEDARVIEW" ] || \
|
|
|
|
[ "$cpu_model" = "$INTEL_FAM6_ATOM_CLOVERVIEW" ] || \
|
|
|
|
[ "$cpu_model" = "$INTEL_FAM6_ATOM_LINCROFT" ] || \
|
|
|
|
[ "$cpu_model" = "$INTEL_FAM6_ATOM_PENWELL" ] || \
|
|
|
|
[ "$cpu_model" = "$INTEL_FAM6_ATOM_PINEVIEW" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
elif [ "$cpu_family" = 5 ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
2018-03-10 16:02:44 +01:00
|
|
|
[ "$cpu_family" = 4 ] && return 0
|
2018-01-31 14:21:29 +01:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2018-01-09 13:37:26 +01:00
|
|
|
show_header()
|
|
|
|
{
|
2018-02-12 18:13:44 +01:00
|
|
|
_info "Spectre and Meltdown mitigation detection tool v$VERSION"
|
2018-01-09 13:37:26 +01:00
|
|
|
_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
|
2018-01-29 10:29:48 +01:00
|
|
|
opt_kernel=$(parse_opt_file kernel "$2"); ret=$?
|
|
|
|
[ $ret -ne 0 ] && exit 255
|
2018-01-08 20:50:42 +01:00
|
|
|
shift 2
|
|
|
|
opt_live=0
|
|
|
|
elif [ "$1" = "--config" ]; then
|
2018-01-29 10:29:48 +01:00
|
|
|
opt_config=$(parse_opt_file config "$2"); ret=$?
|
|
|
|
[ $ret -ne 0 ] && exit 255
|
2018-01-08 20:50:42 +01:00
|
|
|
shift 2
|
|
|
|
opt_live=0
|
|
|
|
elif [ "$1" = "--map" ]; then
|
2018-01-29 10:29:48 +01:00
|
|
|
opt_map=$(parse_opt_file map "$2"); ret=$?
|
|
|
|
[ $ret -ne 0 ] && exit 255
|
2018-01-08 20:50:42 +01:00
|
|
|
shift 2
|
|
|
|
opt_live=0
|
2018-03-17 13:17:10 +01:00
|
|
|
elif [ "$1" = "--arch-prefix" ]; then
|
|
|
|
opt_arch_prefix="$2"
|
|
|
|
shift 2
|
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-21 18:02:11 +01:00
|
|
|
elif [ "$1" = "--sysfs-only" ]; then
|
|
|
|
opt_sysfs_only=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-03-25 12:48:37 +02:00
|
|
|
elif [ "$1" = "--hw-only" ]; then
|
|
|
|
opt_hw_only=1
|
|
|
|
shift
|
2018-04-03 19:34:24 +02:00
|
|
|
elif [ "$1" = "--no-hw" ]; then
|
|
|
|
opt_no_hw=1
|
|
|
|
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-02-25 16:51:42 +01:00
|
|
|
text|nrpe|json|prometheus) 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-29 10:29:48 +01:00
|
|
|
elif [ "$1" = "-v" ] || [ "$1" = "--verbose" ]; then
|
|
|
|
opt_verbose=$(( opt_verbose + 1 ))
|
2018-01-09 13:37:26 +01:00
|
|
|
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-29 10:29:48 +01:00
|
|
|
elif [ "$1" = "-h" ] || [ "$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-29 10:29:48 +01:00
|
|
|
if [ "$opt_no_sysfs" = 1 ] && [ "$opt_sysfs_only" = 1 ]; then
|
2018-01-21 18:02:11 +01:00
|
|
|
_warn "Incompatible options specified (--no-sysfs and --sysfs-only), aborting"
|
|
|
|
exit 255
|
|
|
|
fi
|
|
|
|
|
2018-04-03 19:34:24 +02:00
|
|
|
if [ "$opt_no_hw" = 1 ] && [ "$opt_hw_only" = 1 ]; then
|
|
|
|
_warn "Incompatible options specified (--no-hw and --hw-only), aborting"
|
|
|
|
exit 255
|
|
|
|
fi
|
|
|
|
|
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
|
2018-01-21 12:32:22 +01:00
|
|
|
red) col="\033[41m\033[30m";;
|
|
|
|
green) col="\033[42m\033[30m";;
|
|
|
|
yellow) col="\033[43m\033[30m";;
|
|
|
|
blue) col="\033[44m\033[30m";;
|
2018-01-09 13:04:49 +01:00
|
|
|
*) 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-04-04 23:58:15 +02:00
|
|
|
unset col
|
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-02-25 16:51:42 +01:00
|
|
|
case "$1" in
|
|
|
|
CVE-2017-5753) aka="SPECTRE VARIANT 1";;
|
|
|
|
CVE-2017-5715) aka="SPECTRE VARIANT 2";;
|
|
|
|
CVE-2017-5754) aka="MELTDOWN";;
|
|
|
|
esac
|
|
|
|
|
2018-01-13 20:33:12 +01:00
|
|
|
case "$opt_batch_format" in
|
|
|
|
text) _echo 0 "$1: $2 ($3)";;
|
|
|
|
json)
|
|
|
|
case "$2" in
|
|
|
|
UNK) is_vuln="null";;
|
|
|
|
VULN) is_vuln="true";;
|
|
|
|
OK) is_vuln="false";;
|
|
|
|
esac
|
2018-01-29 10:29:48 +01:00
|
|
|
json_output="${json_output:-[}{\"NAME\":\"$aka\",\"CVE\":\"$1\",\"VULNERABLE\":$is_vuln,\"INFOS\":\"$3\"},"
|
2018-01-13 20:33:12 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
nrpe) [ "$2" = VULN ] && nrpe_vuln="$nrpe_vuln $1";;
|
2018-02-25 16:51:42 +01:00
|
|
|
prometheus)
|
|
|
|
prometheus_output="${prometheus_output:+$prometheus_output\n}specex_vuln_status{name=\"$aka\",cve=\"$1\",status=\"$2\",info=\"$3\"} 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).
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2018-04-01 17:29:12 +02:00
|
|
|
kernel=''
|
|
|
|
kernel_err=''
|
|
|
|
check_kernel()
|
2018-01-09 13:04:49 +01:00
|
|
|
{
|
2018-03-24 23:58:13 +01:00
|
|
|
_file="$1"
|
|
|
|
_desperate_mode="$2"
|
2018-03-17 16:02:11 +01:00
|
|
|
# checking the return code of readelf -h is not enough, we could get
|
|
|
|
# a damaged ELF file and validate it, check for stderr warnings too
|
2018-03-24 23:58:13 +01:00
|
|
|
_readelf_warnings=$("${opt_arch_prefix}readelf" -S "$_file" 2>&1 >/dev/null | tr "\n" "/"); ret=$?
|
|
|
|
_readelf_sections=$("${opt_arch_prefix}readelf" -S "$_file" 2>/dev/null | grep -c -e data -e text -e init)
|
2018-04-01 17:29:12 +02:00
|
|
|
_kernel_size=$(stat -c %s "$_file" 2>/dev/null || stat -f %z "$_file" 2>/dev/null || echo 10000)
|
|
|
|
_debug "check_kernel: ret=$? size=$_kernel_size sections=$_readelf_sections warnings=$_readelf_warnings"
|
2018-03-24 23:58:13 +01:00
|
|
|
if [ -n "$_desperate_mode" ]; then
|
|
|
|
if "${opt_arch_prefix}strings" "$_file" | grep -Eq '^Linux version '; then
|
2018-04-01 17:29:12 +02:00
|
|
|
_debug "check_kernel (desperate): ... matched!"
|
2018-03-24 23:58:13 +01:00
|
|
|
return 0
|
|
|
|
else
|
2018-04-01 17:29:12 +02:00
|
|
|
_debug "check_kernel (desperate): ... invalid"
|
2018-03-24 23:58:13 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ $ret -eq 0 ] && [ -z "$_readelf_warnings" ] && [ "$_readelf_sections" -gt 0 ]; then
|
2018-04-01 17:29:12 +02:00
|
|
|
if [ "$_kernel_size" -ge 100000 ]; then
|
|
|
|
_debug "check_kernel: ... file is valid"
|
2018-03-24 23:58:13 +01:00
|
|
|
return 0
|
|
|
|
else
|
2018-04-01 17:29:12 +02:00
|
|
|
_debug "check_kernel: ... file seems valid but is too small, ignoring"
|
2018-03-24 23:58:13 +01:00
|
|
|
fi
|
|
|
|
else
|
2018-04-01 17:29:12 +02:00
|
|
|
_debug "check_kernel: ... file is invalid"
|
2018-03-24 23:58:13 +01:00
|
|
|
fi
|
2018-03-17 16:02:11 +01:00
|
|
|
fi
|
2018-01-18 11:01:26 +01:00
|
|
|
return 1
|
2018-01-09 13:04:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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-03-17 13:34:53 +01:00
|
|
|
_debug "try_decompress: looking for $3 magic in $6"
|
2018-01-29 10:29:48 +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
|
2018-04-01 17:29:12 +02:00
|
|
|
kernel_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-29 10:29:48 +01:00
|
|
|
# shellcheck disable=SC2086
|
2018-04-01 17:29:12 +02:00
|
|
|
tail -c+$pos "$6" 2>/dev/null | $3 $4 > "$kerneltmp" 2>/dev/null; ret=$?
|
|
|
|
if [ ! -s "$kerneltmp" ]; then
|
2018-03-17 13:34:53 +01:00
|
|
|
# don't rely on $ret, sometimes it's != 0 but worked
|
|
|
|
# (e.g. gunzip ret=2 just means there was trailing garbage)
|
|
|
|
_debug "try_decompress: decompression with $3 failed (err=$ret)"
|
2018-04-01 17:29:12 +02:00
|
|
|
elif check_kernel "$kerneltmp" "$7"; then
|
|
|
|
kernel="$kerneltmp"
|
2018-01-10 20:10:57 +01:00
|
|
|
_debug "try_decompress: decompressed with $3 successfully!"
|
|
|
|
return 0
|
2018-03-17 13:34:53 +01:00
|
|
|
elif [ "$3" != "cat" ]; then
|
|
|
|
_debug "try_decompress: decompression with $3 worked but result is not a kernel, trying with an offset"
|
2018-04-01 17:29:12 +02:00
|
|
|
[ -z "$kerneltmp2" ] && kerneltmp2=$(mktemp /tmp/kernel-XXXXXX)
|
|
|
|
cat "$kerneltmp" > "$kerneltmp2"
|
|
|
|
try_decompress '\177ELF' xxy 'cat' '' cat "$kerneltmp2" && return 0
|
2018-01-10 20:10:57 +01:00
|
|
|
else
|
2018-03-17 13:34:53 +01:00
|
|
|
_debug "try_decompress: decompression with $3 worked but result is not a kernel"
|
2018-01-10 20:10:57 +01:00
|
|
|
fi
|
2018-01-09 13:04:49 +01:00
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2018-04-01 17:29:12 +02:00
|
|
|
extract_kernel()
|
2018-01-09 13:04:49 +01:00
|
|
|
{
|
|
|
|
[ -n "$1" ] || return 1
|
|
|
|
# Prepare temp files:
|
2018-04-01 17:29:12 +02:00
|
|
|
kerneltmp="$(mktemp /tmp/kernel-XXXXXX)"
|
2018-01-09 13:04:49 +01:00
|
|
|
|
|
|
|
# Initial attempt for uncompressed images or objects:
|
2018-04-01 17:29:12 +02:00
|
|
|
if check_kernel "$1"; then
|
|
|
|
cat "$1" > "$kerneltmp"
|
|
|
|
kernel=$kerneltmp
|
2018-01-09 13:04:49 +01:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# That didn't work, so retry after decompression.
|
2018-03-24 23:58:13 +01:00
|
|
|
for mode in '' 'desperate'; do
|
|