Commit dbde07f0 authored by Ian Rogers's avatar Ian Rogers Committed by Peter Zijlstra
Browse files

perf/x86: Fix potential bad container_of in intel_pmu_hw_config



Auto counter reload may have a group of events with software events
present within it. The software event PMU isn't the x86_hybrid_pmu and
a container_of operation in intel_pmu_set_acr_caused_constr (via the
hybrid helper) could cause out of bound memory reads. Avoid this by
guarding the call to intel_pmu_set_acr_caused_constr with an
is_x86_event check.

Fixes: ec980e4f ("perf/x86/intel: Support auto counter reload")
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarThomas Falcon <thomas.falcon@intel.com>
Link: https://patch.msgid.link/20260312194305.1834035-1-irogers@google.com
parent 7aaa8047
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -4855,9 +4855,11 @@ static int intel_pmu_hw_config(struct perf_event *event)
		intel_pmu_set_acr_caused_constr(leader, idx++, cause_mask);

		if (leader->nr_siblings) {
			for_each_sibling_event(sibling, leader)
			for_each_sibling_event(sibling, leader) {
				if (is_x86_event(sibling))
					intel_pmu_set_acr_caused_constr(sibling, idx++, cause_mask);
			}
		}

		if (leader != event)
			intel_pmu_set_acr_caused_constr(event, idx, cause_mask);