[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <170135139956.398.13686814243901771133.tip-bot2@tip-bot2>
Date: Thu, 30 Nov 2023 13:36:39 -0000
From: "tip-bot2 for Alexander Antonov" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Kyle Meyer <kyle.meyer@....com>,
Alexander Antonov <alexander.antonov@...ux.intel.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Kan Liang <kan.liang@...ux.intel.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: perf/core] perf/x86/intel/uncore: Fix NULL pointer dereference
issue in upi_fill_topology()
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 1692cf434ba13ee212495b5af795b6a07e986ce4
Gitweb: https://git.kernel.org/tip/1692cf434ba13ee212495b5af795b6a07e986ce4
Author: Alexander Antonov <alexander.antonov@...ux.intel.com>
AuthorDate: Mon, 27 Nov 2023 10:52:45 -08:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Thu, 30 Nov 2023 14:29:52 +01:00
perf/x86/intel/uncore: Fix NULL pointer dereference issue in upi_fill_topology()
Get logical socket id instead of physical id in discover_upi_topology()
to avoid out-of-bound access on 'upi = &type->topology[nid][idx];' line
that leads to NULL pointer dereference in upi_fill_topology()
Fixes: f680b6e6062e ("perf/x86/intel/uncore: Enable UPI topology discovery for Icelake Server")
Reported-by: Kyle Meyer <kyle.meyer@....com>
Signed-off-by: Alexander Antonov <alexander.antonov@...ux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Kan Liang <kan.liang@...ux.intel.com>
Tested-by: Kyle Meyer <kyle.meyer@....com>
Link: https://lore.kernel.org/r/20231127185246.2371939-2-alexander.antonov@linux.intel.com
---
arch/x86/events/intel/uncore_snbep.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index aeaa8ef..1efbacf 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -5596,7 +5596,7 @@ static int discover_upi_topology(struct intel_uncore_type *type, int ubox_did, i
struct pci_dev *ubox = NULL;
struct pci_dev *dev = NULL;
u32 nid, gid;
- int i, idx, ret = -EPERM;
+ int i, idx, lgc_pkg, ret = -EPERM;
struct intel_uncore_topology *upi;
unsigned int devfn;
@@ -5614,8 +5614,13 @@ static int discover_upi_topology(struct intel_uncore_type *type, int ubox_did, i
for (i = 0; i < 8; i++) {
if (nid != GIDNIDMAP(gid, i))
continue;
+ lgc_pkg = topology_phys_to_logical_pkg(i);
+ if (lgc_pkg < 0) {
+ ret = -EPERM;
+ goto err;
+ }
for (idx = 0; idx < type->num_boxes; idx++) {
- upi = &type->topology[nid][idx];
+ upi = &type->topology[lgc_pkg][idx];
devfn = PCI_DEVFN(dev_link0 + idx, ICX_UPI_REGS_ADDR_FUNCTION);
dev = pci_get_domain_bus_and_slot(pci_domain_nr(ubox->bus),
ubox->bus->number,
@@ -5626,6 +5631,7 @@ static int discover_upi_topology(struct intel_uncore_type *type, int ubox_did, i
goto err;
}
}
+ break;
}
}
err:
Powered by blists - more mailing lists