[PATCH 0/3] lib: fwts_cpu: bug fixes and improvements

Ricardo Neri ricardo.neri-calderon at linux.intel.com
Fri Jul 8 23:42:18 UTC 2016


Hi,

As part of the integration of FWTS with the Linux* UEFI Validation project,
we came across a segmentation fault when running test cases that used the
fwts_cpu_get_info function. Our kernel had the CONFIG_BOOTPARAM_HOTPLUG_CPU0
option selected. Thus, CPU0 was offline. All callers of the aforementioned
function query CPU0. In such a case, an empty structure is returned; along
with NULL pointers. Some callers blindly dereference members of the
structure leading to a segmentation fault.

The first patch of the series addresses the problem described above. The
second patch addresses the fact that an empty structure is useless and makes
fwts_cpu_get_info return a NULL in such situation. No functional changes
thus far.

The last patch may call for further discussion. Addressing the fact that in
certain scenarios CPU0 may be offline, the last patch proposes a change in
functionality to query the first available CPU rather than CPU0.
To my knowledge, this should have no further implications as we assume that
all the CPUs yield the same properties. If this is not the case, then more
logic needs to be added to fail the impacted test cases when the info of an
offline CPU is requested.

Thanks and BR,
Ricardo


Ricardo Neri (3):
  fwts_cpuinfo_x86: check for null pointers when using
  lib: fwts_cpu: return info struct only when requested CPU is found
  lib: fwts_cpu: query info from the first online CPU

 src/bios/mtrr/mtrr.c   |  6 +++++-
 src/cpu/msr/msr.c      |  2 +-
 src/cpu/nx/nx.c        | 22 +++++++++++++++++++---
 src/cpu/virt/virt.c    | 12 +++++++++++-
 src/lib/src/fwts_cpu.c | 32 +++++++++++++++++++++++++++-----
 5 files changed, 63 insertions(+), 11 deletions(-)

-- 
2.9.0




More information about the fwts-devel mailing list