Date: Wed, 4 Aug 2021 18:24:32 GMT From: Mitchell Horne <mhorne@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 8399d923a569 - main - hwpmc_intel: assert for correct nclasses value Message-ID: <202108041824.174IOW8R001490@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=8399d923a5697b7c194dbd44c33018c94ec42c4e commit 8399d923a5697b7c194dbd44c33018c94ec42c4e Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2021-08-04 17:37:05 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2021-08-04 18:23:22 +0000 hwpmc_intel: assert for correct nclasses value This variable is set based on the exact CPU model detected. If this value is set too small, it could lead to a NULL-dereference from an improperly initialized pmc_rowindex_to_classdep array. Though it has been fixed, this was previously the case for Broadwell. Add two asserts to catch this in DEBUG kernels, as it represents a configuration error that may be hard to uncover otherwise. PR: 253687 Reported by: Zhenlei Huang <zlei.huang@gmail.com> Sponsored by: The FreeBSD Foundation --- sys/dev/hwpmc/hwpmc_intel.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/hwpmc/hwpmc_intel.c b/sys/dev/hwpmc/hwpmc_intel.c index 02b8fd9431d1..6cc6ae3b50d6 100644 --- a/sys/dev/hwpmc/hwpmc_intel.c +++ b/sys/dev/hwpmc/hwpmc_intel.c @@ -255,6 +255,7 @@ pmc_intel_initialize(void) case PMC_CPU_INTEL_IVYBRIDGE_XEON: case PMC_CPU_INTEL_HASWELL: case PMC_CPU_INTEL_HASWELL_XEON: + MPASS(nclasses >= PMC_MDEP_CLASS_INDEX_IAF); error = pmc_core_initialize(pmc_mdep, ncpus, verov); break; @@ -296,6 +297,7 @@ pmc_intel_initialize(void) case PMC_CPU_INTEL_BROADWELL: case PMC_CPU_INTEL_SANDYBRIDGE: #endif + MPASS(nclasses >= PMC_MDEP_CLASS_INDEX_UCF); error = pmc_uncore_initialize(pmc_mdep, ncpus); break; default:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108041824.174IOW8R001490>