Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern In ksem_close_fop(), if we get a pshared semaphore ...
details: https://anonhg.NetBSD.org/src/rev/e2fb9d6e63cc
branches: trunk
changeset: 448553:e2fb9d6e63cc
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Feb 05 07:14:32 2019 +0000
description:
In ksem_close_fop(), if we get a pshared semaphore that's not already
been marked dead, make sure we mark it so if the owner proc is the proc
closing it. (This case can happen if a process sem_init()'s a pshared
semaphore and then exits without destroying it.)
Fixes kern/53942.
diffstat:
sys/kern/uipc_sem.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diffs (41 lines):
diff -r 5c5491b12f70 -r e2fb9d6e63cc sys/kern/uipc_sem.c
--- a/sys/kern/uipc_sem.c Tue Feb 05 06:46:47 2019 +0000
+++ b/sys/kern/uipc_sem.c Tue Feb 05 07:14:32 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_sem.c,v 1.52 2019/02/03 03:20:23 thorpej Exp $ */
+/* $NetBSD: uipc_sem.c,v 1.53 2019/02/05 07:14:32 thorpej Exp $ */
/*-
* Copyright (c) 2011, 2019 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.52 2019/02/03 03:20:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.53 2019/02/05 07:14:32 thorpej Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -840,12 +840,18 @@
{
ksem_t *ks = fp->f_ksem;
- if (ks->ks_pshared_id != 0 && ks->ks_pshared_proc != curproc) {
- /* Do nothing if this is not the creator. */
- return 0;
+ mutex_enter(&ks->ks_lock);
+
+ if (ks->ks_pshared_id) {
+ if (ks->ks_pshared_proc != curproc) {
+ /* Do nothing if this is not the creator. */
+ mutex_exit(&ks->ks_lock);
+ return 0;
+ }
+ /* Mark this semaphore as dead. */
+ ks->ks_pshared_proc = NULL;
}
- mutex_enter(&ks->ks_lock);
ksem_release(ks, -1);
return 0;
}
Home |
Main Index |
Thread Index |
Old Index