Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Nov 2017 19:10:14 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r325671 - head/sys/dev/hwpmc
Message-ID:  <201711101910.vAAJAE3q049962@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Nov 10 19:10:14 2017
New Revision: 325671
URL: https://svnweb.freebsd.org/changeset/base/325671

Log:
  Check that the pmc index is less than the number of hardware PMCs,
  instead of asserting the condition.
  
  The row index is directly supplied by userspace, the kernel must
  handle invalid values.
  
  Submitted by:	pho
  MFC after:	3 days

Modified:
  head/sys/dev/hwpmc/hwpmc_mod.c

Modified: head/sys/dev/hwpmc/hwpmc_mod.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_mod.c	Fri Nov 10 18:46:34 2017	(r325670)
+++ head/sys/dev/hwpmc/hwpmc_mod.c	Fri Nov 10 19:10:14 2017	(r325671)
@@ -2578,10 +2578,9 @@ pmc_find_pmc(pmc_id_t pmcid, struct pmc **pmc)
 	struct pmc_owner *po;
 	struct pmc_process *pp;
 
-	KASSERT(PMC_ID_TO_ROWINDEX(pmcid) < md->pmd_npmc,
-	    ("[pmc,%d] Illegal pmc index %d (max %d)", __LINE__,
-		PMC_ID_TO_ROWINDEX(pmcid), md->pmd_npmc));
 	PMCDBG1(PMC,FND,1, "find-pmc id=%d", pmcid);
+	if (PMC_ID_TO_ROWINDEX(pmcid) >= md->pmd_npmc)
+		return (EINVAL);
 
 	if ((po = pmc_find_owner_descriptor(curthread->td_proc)) == NULL) {
 		/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711101910.vAAJAE3q049962>