@@ -1892,7 +1892,7 @@ dmesg_grep()
18921892 # dmesg truncated
18931893 return 2
18941894 fi
1895- dmesg_grepped=$( dmesg | grep -E " $1 " | head -1 )
1895+ dmesg_grepped=$( dmesg | grep -E " $1 " | head -n1 )
18961896 # not found:
18971897 [ -z " $dmesg_grepped " ] && return 1
18981898 # found, output is in $dmesg_grepped
@@ -2186,8 +2186,8 @@ parse_cpu_details()
21862186 if [ -e " $procfs /cpuinfo" ]; then
21872187 if grep -qw avx2 " $procfs /cpuinfo" 2> /dev/null; then has_avx2=1; fi
21882188 if grep -qw avx512 " $procfs /cpuinfo" 2> /dev/null; then has_avx512=1; fi
2189- cpu_vendor=$( grep ' ^vendor_id' " $procfs /cpuinfo" | awk ' {print $3}' | head -1 )
2190- cpu_friendly_name=$( grep ' ^model name' " $procfs /cpuinfo" | cut -d: -f2- | head -1 | sed -e ' s/^ *//' )
2189+ cpu_vendor=$( grep ' ^vendor_id' " $procfs /cpuinfo" | awk ' {print $3}' | head -n1 )
2190+ cpu_friendly_name=$( grep ' ^model name' " $procfs /cpuinfo" | cut -d: -f2- | head -n1 | sed -e ' s/^ *//' )
21912191 # special case for ARM follows
21922192 if grep -qi ' CPU implementer[[:space:]]*:[[:space:]]*0x41' " $procfs /cpuinfo" ; then
21932193 cpu_vendor=' ARM'
@@ -2211,10 +2211,10 @@ parse_cpu_details()
22112211 cpu_vendor=' PHYTIUM'
22122212 fi
22132213
2214- cpu_family=$( grep ' ^cpu family' " $procfs /cpuinfo" | awk ' {print $4}' | grep -E ' ^[0-9]+$' | head -1 )
2215- cpu_model=$( grep ' ^model' " $procfs /cpuinfo" | awk ' {print $3}' | grep -E ' ^[0-9]+$' | head -1 )
2216- cpu_stepping=$( grep ' ^stepping' " $procfs /cpuinfo" | awk ' {print $3}' | grep -E ' ^[0-9]+$' | head -1 )
2217- cpu_ucode=$( grep ' ^microcode' " $procfs /cpuinfo" | awk ' {print $3}' | head -1 )
2214+ cpu_family=$( grep ' ^cpu family' " $procfs /cpuinfo" | awk ' {print $4}' | grep -E ' ^[0-9]+$' | head -n1 )
2215+ cpu_model=$( grep ' ^model' " $procfs /cpuinfo" | awk ' {print $3}' | grep -E ' ^[0-9]+$' | head -n1 )
2216+ cpu_stepping=$( grep ' ^stepping' " $procfs /cpuinfo" | awk ' {print $3}' | grep -E ' ^[0-9]+$' | head -n1 )
2217+ cpu_ucode=$( grep ' ^microcode' " $procfs /cpuinfo" | awk ' {print $3}' | head -n1 )
22182218 else
22192219 cpu_vendor=$( dmesg | grep -i -m1 ' Origin=' | cut -f2 -w | cut -f2 -d= | cut -f2 -d\" )
22202220 cpu_family=$( dmesg | grep -i -m1 ' Family=' | cut -f4 -w | cut -f2 -d= )
@@ -2995,7 +2995,7 @@ else
29952995 kernel_version=$( " ${opt_arch_prefix} strings" " $kernel " 2> /dev/null | grep -E \
29962996 -e ' ^Linux version ' \
29972997 -e ' ^[[:alnum:]][^[:space:]]+ \([^[:space:]]+\) #[0-9]+ .+ (19|20)[0-9][0-9]$' \
2998- -e ' ^FreeBSD [0-9]' | grep -v ' ABI compat' | head -1 )
2998+ -e ' ^FreeBSD [0-9]' | grep -v ' ABI compat' | head -n1 )
29992999 if [ -z " $kernel_version " ]; then
30003000 # try even harder with some kernels (such as ARM) that split the release (uname -r) and version (uname -v) in 2 adjacent strings
30013001 kernel_version=$( " ${opt_arch_prefix} strings" " $kernel " 2> /dev/null | grep -E -B1 ' ^#[0-9]+ .+ (19|20)[0-9][0-9]$' | tr " \n" " " )
@@ -4245,7 +4245,7 @@ check_CVE_2017_5715_linux()
42454245 :
42464246 else
42474247 ibrs_can_tell=1
4248- ibrs_supported=$( " ${opt_arch_prefix} strings" " $kernel " | grep -Fw -e ' , IBRS_FW' | head -1 )
4248+ ibrs_supported=$( " ${opt_arch_prefix} strings" " $kernel " | grep -Fw -e ' , IBRS_FW' | head -n1 )
42494249 if [ -n " $ibrs_supported " ]; then
42504250 _debug " ibrs: found ibrs evidence in kernel image ($ibrs_supported )"
42514251 ibrs_supported=" found '$ibrs_supported ' in kernel image"
@@ -4266,7 +4266,7 @@ check_CVE_2017_5715_linux()
42664266 :
42674267 else
42684268 ibpb_can_tell=1
4269- ibpb_supported=$( " ${opt_arch_prefix} strings" " $kernel " | grep -Fw -e ' ibpb' -e ' , IBPB' | head -1 )
4269+ ibpb_supported=$( " ${opt_arch_prefix} strings" " $kernel " | grep -Fw -e ' ibpb' -e ' , IBPB' | head -n1 )
42704270 if [ -n " $ibpb_supported " ]; then
42714271 _debug " ibpb: found ibpb evidence in kernel image ($ibpb_supported )"
42724272 ibpb_supported=" found '$ibpb_supported ' in kernel image"
@@ -4857,7 +4857,7 @@ check_CVE_2017_5754_linux()
48574857 kpti_enabled=$( cat /sys/kernel/debug/x86/pti_enabled 2> /dev/null)
48584858 _debug " kpti_enabled: file /sys/kernel/debug/x86/pti_enabled exists and says: $kpti_enabled "
48594859 elif is_xen_dom0; then
4860- pti_xen_pv_domU=$( xl dmesg | grep ' XPTI' | grep ' DomU enabled' | head -1 )
4860+ pti_xen_pv_domU=$( xl dmesg | grep ' XPTI' | grep ' DomU enabled' | head -n1 )
48614861
48624862 [ -n " $pti_xen_pv_domU " ] && kpti_enabled=1
48634863 fi
@@ -5475,9 +5475,9 @@ check_CVE_2018_3646_linux()
54755475 pstatus green YES " unconditional flushes"
54765476 else
54775477 if is_xen_dom0; then
5478- l1d_xen_hardware=$( xl dmesg | grep ' Hardware features:' | grep ' L1D_FLUSH' | head -1 )
5479- l1d_xen_hypervisor=$( xl dmesg | grep ' Xen settings:' | grep ' L1D_FLUSH' | head -1 )
5480- l1d_xen_pv_domU=$( xl dmesg | grep ' PV L1TF shadowing:' | grep ' DomU enabled' | head -1 )
5478+ l1d_xen_hardware=$( xl dmesg | grep ' Hardware features:' | grep ' L1D_FLUSH' | head -n1 )
5479+ l1d_xen_hypervisor=$( xl dmesg | grep ' Xen settings:' | grep ' L1D_FLUSH' | head -n1 )
5480+ l1d_xen_pv_domU=$( xl dmesg | grep ' PV L1TF shadowing:' | grep ' DomU enabled' | head -n1 )
54815481
54825482 if [ -n " $l1d_xen_hardware " ] && [ -n " $l1d_xen_hypervisor " ] && [ -n " $l1d_xen_pv_domU " ]; then
54835483 l1d_mode=5
0 commit comments