diff options
author | Stéphane Lesimple <speed47_github@speed47.net> | 2018-01-18 11:01:26 +0100 |
---|---|---|
committer | Stéphane Lesimple <speed47_github@speed47.net> | 2018-01-20 12:23:55 +0100 |
commit | 7fa2d6347bf5c029dcc74aaa05355c3873dad0b4 (patch) | |
tree | 828aa70f0b199f772fd8549d83d5deca141e055f | |
parent | 3be5e904818a440c3c63261eb16ee095e8e9a996 (diff) | |
download | spectre-meltdown-checker-7fa2d6347bf5c029dcc74aaa05355c3873dad0b4.tar.lz spectre-meltdown-checker-7fa2d6347bf5c029dcc74aaa05355c3873dad0b4.tar.xz spectre-meltdown-checker-7fa2d6347bf5c029dcc74aaa05355c3873dad0b4.zip |
check_vmlinux: when readelf doesn't work, try harder with another way
-rwxr-xr-x | spectre-meltdown-checker.sh | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/spectre-meltdown-checker.sh b/spectre-meltdown-checker.sh index 32f7442..2f964af 100755 --- a/spectre-meltdown-checker.sh +++ b/spectre-meltdown-checker.sh @@ -438,8 +438,18 @@ vmlinux='' vmlinux_err='' check_vmlinux() { - readelf -h "$1" > /dev/null 2>&1 || return 1 - return 0 + readelf -h "$1" > /dev/null 2>&1 && return 0 + # normally we would just use readelf to test for the binary, and it would be sufficient. + # but for some archs/distros it doesn't work well (issue #82), so we add a dumber check: + # uncompressed kernels always have the following string present + if ! which strings >/dev/null 2>&1; then + vmlinux_err="missing 'strings' tool, please install it, usually it's in the 'binutils' package" + return 0 + else + strings "$1" | grep -q '^Linux version ' && return 0 + fi + # not found: kernel not valid + return 1 } try_decompress() |