Skip to content

Fix NULL pointer dereference issue during discovering UPI topology

[email protected] lkml 2 versions – Applied

Status from this message: The following commit has been merged into the perf/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 1 replyApplied
  2. v11 patch 4 repliesSuperseded

Changes in v2 from the cover letter

1. Factor out topology_gidnid_map() with common code for GIDNIDMAP procedure

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/2perf/x86/intel/uncore: Fix NULL pointer dereference issue in upi_fill_topology()arch/x86/events/intel/uncore_snbep.c+8 -20 replies
2/2perf/x86/intel/uncore: Factor out topology_gidnid_map()arch/x86/events/intel/uncore_snbep.c+40 -370 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchKyle MeyerKan Liang
SeriesR-b
1/2T-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] Fix NULL pointer dereference issue during discovering UPI topology

From: Alexander Antonov <[email protected]>

The NULL dereference happens inside upi_fill_topology() procedure in case of disabling one of the sockets on the system.

For example, if you disable the 2nd socket on a 4-socket system then uncore_max_dies() returns 3 and inside pmu_alloc_topology() memory will be allocated only for 3 sockets and stored in type->topology. In discover_upi_topology() memory is accessed by socket id from CPUNODEID registers which contain physical ids (from 0 to 3) and on the line:

    upi = &type->topology[nid][idx];

out-of-bound access will happen and the 'upi' pointer will be passed to upi_fill_topology() where it will be dereferenced.

To avoid this issue update the code to convert physical socket id to logical socket id in discover_upi_topology() before accessing memory.

Changed in v2:
1. Factor out topology_gidnid_map() with common code for GIDNIDMAP procedure

Alexander Antonov (2):
perf/x86/intel/uncore: Fix NULL pointer dereference issue in
upi_fill_topology()
perf/x86/intel/uncore: Factor out topology_gidnid_map()

 arch/x86/events/intel/uncore_snbep.c | 71 ++++++++++++++++------------
 1 file changed, 40 insertions(+), 31 deletions(-)
Signature · 1 line
2.25.1