# vim: set ts=4 sw=4 sts=4 et: # Print command-line usage information to stdout show_usage() { # shellcheck disable=SC2086 cat <] [--config ] [--map ] No-runtime: $(basename $0) [options] --no-runtime <--kernel > [--config ] [--map ] No-hw: $(basename $0) [options] --no-hw <--kernel > [--config ] [--map ] Modes: Three modes are available. 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 optionally specify --kernel, --config, or --map to help the script locate files it couldn't auto-detect, without changing the mode. --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) Second mode is "no-runtime" (--no-runtime), where the script inspects the local CPU hardware but skips all running-kernel artifacts (/sys, /proc, dmesg). Use this when you have a kernel image from another system but want to check it against this CPU. Third mode is "no-hw" (--no-hw), where the script skips both CPU hardware inspection and running-kernel artifacts. Use this for pure static analysis of a kernel image, for example when inspecting an embedded kernel from a different architecture. Options: --no-color don't use color codes --verbose, -v increase verbosity level, possibly several times --explain produce an additional human-readable explanation of actions to take to mitigate a vulnerability --paranoid require all mitigations to be enabled to the fullest extent, including those that are not strictly necessary but provide defense in depth (e.g. SMT disabled, IBPB always-on); without this flag, the script follows the security community consensus --extra run additional checks for issues that don't have a CVE but are still security-relevant, such as compile-time mitigations not enabled by default (e.g. Straight-Line Speculation) --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 short produce only one line with the vulnerabilities separated by spaces --batch json produce comprehensive JSON output with system, CPU, and vulnerability details --batch json-terse produce a terse JSON array of per-CVE results (legacy format) --batch nrpe produce machine readable output formatted for NRPE --batch prometheus produce Prometheus metrics (smc_* schema) --variant VARIANT specify which variant you'd like to check, by default all variants are checked. can be used multiple times (e.g. --variant 3a --variant l1tf) for a list of supported VARIANT parameters, use --variant help --cve CVE specify which CVE you'd like to check, by default all supported CVEs are checked can be used multiple times (e.g. --cve CVE-2017-5753 --cve CVE-2020-0543) --hw-only only check for CPU information, don't check for any variant --no-runtime skip running-kernel checks (/sys, /proc, dmesg), still inspect local CPU hardware --no-hw skip CPU information and running-kernel checks (implies --no-runtime) --vmm [auto,yes,no] override the detection of the presence of a hypervisor, default: auto --allow-msr-write allow probing for write-only MSRs, this might produce kernel logs or be blocked by your system --cpu [#,all] interact with CPUID and MSR of CPU core number #, or all (default: CPU core 0) --update-fwdb update our local copy of the CPU microcodes versions database (using the awesome MCExtractor project and the Intel firmwares GitHub repository) --update-builtin-fwdb same as --update-fwdb but update builtin DB inside the script itself --dump-mock-data used to mimick a CPU on an other system, mainly used to help debugging this script Return codes: 0 (not vulnerable), 2 (vulnerable), 3 (unknown), 255 (error) 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 } # Print the legal disclaimer about tool accuracy and limitations show_disclaimer() { cat <&2 exit 255 fi echo "$line" | cut -d'|' -f"$2" } # find a sane command to print colored messages, we prefer `printf` over `echo` # because `printf` behavior is more standard across Linux/BSD # we'll try to avoid using shell builtins that might not take options g_echo_cmd_type='echo' # ignore SC2230 here because `which` ignores builtins while `command -v` doesn't, and # we don't want builtins here. Even if `which` is not installed, we'll fallback to the # `echo` builtin anyway, so this is safe. # shellcheck disable=SC2230 if command -v printf >/dev/null 2>&1; then g_echo_cmd=$(command -v printf) g_echo_cmd_type='printf' elif which echo >/dev/null 2>&1; then g_echo_cmd=$(which echo) else # maybe the `which` command is broken? [ -x /bin/echo ] && g_echo_cmd=/bin/echo # for Android [ -x /system/bin/echo ] && g_echo_cmd=/system/bin/echo fi # still empty? fallback to builtin [ -z "$g_echo_cmd" ] && g_echo_cmd='echo'