linux/arch/x86/events/intel
Tristan Hume 1d9093457b perf/x86/intel/pt: Fix crash with stop filters in single-range mode
Add a check for !buf->single before calling pt_buffer_region_size in a
place where a missing check can cause a kernel crash.

Fixes a bug introduced by commit 670638477a ("perf/x86/intel/pt:
Opportunistically use single range output mode"), which added a
support for PT single-range output mode. Since that commit if a PT
stop filter range is hit while tracing, the kernel will crash because
of a null pointer dereference in pt_handle_status due to calling
pt_buffer_region_size without a ToPA configured.

The commit which introduced single-range mode guarded almost all uses of
the ToPA buffer variables with checks of the buf->single variable, but
missed the case where tracing was stopped by the PT hardware, which
happens when execution hits a configured stop filter.

Tested that hitting a stop filter while PT recording successfully
records a trace with this patch but crashes without this patch.

Fixes: 670638477a ("perf/x86/intel/pt: Opportunistically use single range output mode")
Signed-off-by: Tristan Hume <tristan@thume.ca>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@kernel.org
Link: https://lkml.kernel.org/r/20220127220806.73664-1-tristan@thume.ca
2022-02-02 13:11:40 +01:00
..
bts.c perf/x86: Add compiler barrier after updating BTS 2021-09-17 15:08:38 +02:00
core.c x86/perf: Default set FREEZE_ON_SMI for all 2022-02-02 13:11:39 +01:00
cstate.c perf/x86/cstate: Add ICELAKE_X and ICELAKE_D support 2021-07-02 15:58:33 +02:00
ds.c Core: 2021-11-02 06:20:58 -07:00
knc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lbr.c x86/perf: Avoid warning for Arch LBR without XSAVE 2022-01-18 12:09:49 +01:00
Makefile perf/x86/intel/uncore: Parse uncore discovery tables 2021-04-02 10:04:54 +02:00
p4.c Perf events changes in this cycle were: 2021-04-28 13:03:44 -07:00
p6.c x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-15 01:15:52 +01:00
pt.c perf/x86/intel/pt: Fix crash with stop filters in single-range mode 2022-02-02 13:11:40 +01:00
pt.h perf/x86/intel/pt: Prevent redundant WRMSRs 2019-11-13 11:06:18 +01:00
uncore_discovery.c perf/x86/intel/uncore: Add IMC uncore support for ADL 2022-01-18 12:09:49 +01:00
uncore_discovery.h perf/x86/intel/uncore: Add IMC uncore support for ADL 2022-01-18 12:09:49 +01:00
uncore_nhmex.c perf/x86/intel/uncore: Correct fixed counter index check for NHM 2018-05-31 12:36:28 +02:00
uncore_snb.c perf/x86/intel/uncore: Add IMC uncore support for ADL 2022-01-18 12:09:49 +01:00
uncore_snbep.c perf/x86/intel/uncore: Fix CAS_COUNT_WRITE issue for ICX 2022-01-18 12:09:48 +01:00
uncore.c perf/x86/intel/uncore: Add IMC uncore support for ADL 2022-01-18 12:09:49 +01:00
uncore.h perf/x86/intel/uncore: Add IMC uncore support for ADL 2022-01-18 12:09:49 +01:00