]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: avoid out of bounds indices for fixed performance counters
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 9 Dec 2021 19:10:04 +0000 (14:10 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 7 Jan 2022 15:44:40 +0000 (10:44 -0500)
commit58baec0c36ee97e5f11d5efe02de4ecbd213fee7
treef8d63e8f5fdf5ba23e0cf47f88e1ef4a30f8cc5a
parentab749881f1d3b1f48b77e2ef47ad538061c6afc4
KVM: x86: avoid out of bounds indices for fixed performance counters

Because IceLake has 4 fixed performance counters but KVM only
supports 3, it is possible for reprogram_fixed_counters to pass
to reprogram_fixed_counter an index that is out of bounds for the
fixed_pmc_events array.

Ultimately intel_find_fixed_event, which is the only place that uses
fixed_pmc_events, handles this correctly because it checks against the
size of fixed_pmc_events anyway.  Every other place operates on the
fixed_counters[] array which is sized according to INTEL_PMC_MAX_FIXED.
However, it is cleaner if the unsupported performance counters are culled
early on in reprogram_fixed_counters.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/pmu_intel.c