From 1c0f6d9580fc47731f6a87153da0e446ad4ce7e2 Mon Sep 17 00:00:00 2001 From: rrobgill <35944068+rrobgill@users.noreply.github.com> Date: Fri, 4 May 2018 07:21:48 +1000 Subject: [PATCH 1/2] cpuid and msr module check This adds a check before loading the cpuid and msr modules under linux, ensuring they are not unloaded in exit_cleanup() if they were initially present. --- spectre-meltdown-checker.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/spectre-meltdown-checker.sh b/spectre-meltdown-checker.sh index 5bc94f7..f6f1119 100755 --- a/spectre-meltdown-checker.sh +++ b/spectre-meltdown-checker.sh @@ -732,8 +732,12 @@ mount_debugfs() load_msr() { if [ "$os" = Linux ]; then - modprobe msr 2>/dev/null && insmod_msr=1 - _debug "attempted to load module msr, insmod_msr=$insmod_msr" + if ! grep -e msr /proc/modules 2>/dev/null; then + modprobe msr 2>/dev/null && insmod_msr=1 + _debug "attempted to load module msr, insmod_msr=$insmod_cpuid" + else + _debug "msr module already loaded" + fi else if ! kldstat -q -m cpuctl; then kldload cpuctl 2>/dev/null && kldload_cpuctl=1 @@ -747,8 +751,12 @@ load_msr() load_cpuid() { if [ "$os" = Linux ]; then - modprobe cpuid 2>/dev/null && insmod_cpuid=1 - _debug "attempted to load module cpuid, insmod_cpuid=$insmod_cpuid" + if ! grep -e cpuid /proc/modules 2>/dev/null; then + modprobe cpuid 2>/dev/null && insmod_cpuid=1 + _debug "attempted to load module cpuid, insmod_cpuid=$insmod_cpuid" + else + _debug "cpuid module already loaded" + fi else if ! kldstat -q -m cpuctl; then kldload cpuctl 2>/dev/null && kldload_cpuctl=1 From 5cc77741af1d2f52140aa9f89339f56b6c4b6783 Mon Sep 17 00:00:00 2001 From: rrobgill <35944068+rrobgill@users.noreply.github.com> Date: Fri, 4 May 2018 07:30:54 +1000 Subject: [PATCH 2/2] Update spectre-meltdown-checker.sh --- spectre-meltdown-checker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectre-meltdown-checker.sh b/spectre-meltdown-checker.sh index f6f1119..efa4812 100755 --- a/spectre-meltdown-checker.sh +++ b/spectre-meltdown-checker.sh @@ -734,7 +734,7 @@ load_msr() if [ "$os" = Linux ]; then if ! grep -e msr /proc/modules 2>/dev/null; then modprobe msr 2>/dev/null && insmod_msr=1 - _debug "attempted to load module msr, insmod_msr=$insmod_cpuid" + _debug "attempted to load module msr, insmod_msr=$insmod_msr" else _debug "msr module already loaded" fi