Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Feb 2020 11:05:27 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r358244 - stable/11/sys/kern
Message-ID:  <202002221105.01MB5Rp3077808@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sat Feb 22 11:05:27 2020
New Revision: 358244
URL: https://svnweb.freebsd.org/changeset/base/358244

Log:
  MFC r357983:
  sem_remove(): add some asserts.

Modified:
  stable/11/sys/kern/sysv_sem.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/sysv_sem.c
==============================================================================
--- stable/11/sys/kern/sysv_sem.c	Sat Feb 22 11:04:24 2020	(r358243)
+++ stable/11/sys/kern/sysv_sem.c	Sat Feb 22 11:05:27 2020	(r358244)
@@ -550,8 +550,14 @@ sem_remove(int semidx, struct ucred *cred)
 	int i;
 
 	KASSERT(semidx >= 0 && semidx < seminfo.semmni,
-		("semidx out of bounds"));
+	    ("semidx out of bounds"));
+	mtx_assert(&sem_mtx, MA_OWNED);
 	semakptr = &sema[semidx];
+	KASSERT(semakptr->u.__sem_base - sem + semakptr->u.sem_nsems <= semtot,
+	    ("sem_remove: sema %d corrupted sem pointer %p %p %d %d",
+	    semidx, semakptr->u.__sem_base, sem, semakptr->u.sem_nsems,
+	    semtot));
+
 	semakptr->u.sem_perm.cuid = cred ? cred->cr_uid : 0;
 	semakptr->u.sem_perm.uid = cred ? cred->cr_uid : 0;
 	semakptr->u.sem_perm.mode = 0;



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