summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorEvan Li <evan.li@linux.alibaba.com>2025-12-12 16:49:43 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-12-18 14:03:41 +0100
commit67d5a5e20259414b5ad6ba8bdf1aff8e80ca9c49 (patch)
treea5adb7ff728e97aea27abd99cbd859634c5cbb9b /arch
parentf2091f479f5bd27e9b425d251e869f2a7580b1fa (diff)
downloadlinux-67d5a5e20259414b5ad6ba8bdf1aff8e80ca9c49.tar.gz
linux-67d5a5e20259414b5ad6ba8bdf1aff8e80ca9c49.tar.bz2
linux-67d5a5e20259414b5ad6ba8bdf1aff8e80ca9c49.zip
perf/x86/intel: Fix NULL event dereference crash in handle_pmi_common()
[ Upstream commit 9415f749d34b926b9e4853da1462f4d941f89a0d ] handle_pmi_common() may observe an active bit set in cpuc->active_mask while the corresponding cpuc->events[] entry has already been cleared, which leads to a NULL pointer dereference. This can happen when interrupt throttling stops all events in a group while PEBS processing is still in progress. perf_event_overflow() can trigger perf_event_throttle_group(), which stops the group and clears the cpuc->events[] entry, but the active bit may still be set when handle_pmi_common() iterates over the events. The following recent fix: 7e772a93eb61 ("perf/x86: Fix NULL event access and potential PEBS record loss") moved the cpuc->events[] clearing from x86_pmu_stop() to x86_pmu_del() and relied on cpuc->active_mask/pebs_enabled checks. However, handle_pmi_common() can still encounter a NULL cpuc->events[] entry despite the active bit being set. Add an explicit NULL check on the event pointer before using it, to cover this legitimate scenario and avoid the NULL dereference crash. Fixes: 7e772a93eb61 ("perf/x86: Fix NULL event access and potential PEBS record loss") Reported-by: kitta <kitta@linux.alibaba.com> Co-developed-by: kitta <kitta@linux.alibaba.com> Signed-off-by: Evan Li <evan.li@linux.alibaba.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://patch.msgid.link/20251212084943.2124787-1-evan.li@linux.alibaba.com Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220855 Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/events/intel/core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 9b824ed6fc1d..32d551f2646a 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3249,6 +3249,9 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
if (!test_bit(bit, cpuc->active_mask))
continue;
+ /* Event may have already been cleared: */
+ if (!event)
+ continue;
/*
* There may be unprocessed PEBS records in the PEBS buffer,