NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: PR/53998 CVS commit: src/sys/kern



The following reply was made to PR kern/53998; it has been noted by GNATS.

From: christos%zoulas.com@localhost (Christos Zoulas)
To: gnats-bugs%NetBSD.org@localhost, kern-bug-people%netbsd.org@localhost, 
	gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost, 
	joel.bertrand%systella.fr@localhost
Cc: 
Subject: Re: PR/53998 CVS commit: src/sys/kern
Date: Sun, 24 Feb 2019 15:27:55 -0500

 On Feb 24,  5:20pm, joel.bertrand%systella.fr@localhost (=?UTF-8?Q?BERTRAND_Jo=c3=abl?=) wrote:
 -- Subject: Re: PR/53998 CVS commit: src/sys/kern
 
 I can see the race conditions for p_nsems, but since this intended just
 to be a guard to prevent abuse, it is simple enough to avoid it for now...
 
 christos
 
 Index: uipc_sem.c
 ===================================================================
 RCS file: /cvsroot/src/sys/kern/uipc_sem.c,v
 retrieving revision 1.54
 diff -u -p -u -r1.54 uipc_sem.c
 --- uipc_sem.c	21 Feb 2019 21:49:23 -0000	1.54
 +++ uipc_sem.c	24 Feb 2019 20:25:43 -0000
 @@ -511,7 +511,11 @@ ksem_free(ksem_t *ks)
  	kmem_free(ks, sizeof(ksem_t));
  
  	atomic_dec_uint(&nsems_total);
 - 	atomic_dec_uint(&curproc->p_nsems);	
 + 	while ((int)atomic_dec_uint_nv(&curproc->p_nsems) < 0) {
 +		printf("%s: pid=%d sem=%p negarive refcount %u\n", __func__,
 +		    curproc->p_pid, ks, curproc->p_nsems);
 +		atomic_inc_uint(&curproc->p_nsems);
 +	}
  }
  
  #define	KSEM_ID_IS_PSHARED(id)		\
 


Home | Main Index | Thread Index | Old Index