Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/kern Pull up following revision(s) (requested by maxv...



details:   https://anonhg.NetBSD.org/src/rev/eae14b7a7da0
branches:  netbsd-9
changeset: 962958:eae14b7a7da0
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Sep 10 16:14:53 2019 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #191):

        sys/kern/sysv_shm.c: revision 1.136

Acquire shmseg uobj reference while we hold shm_lock.

Otherwise nothing prevents it from being detached under our feet when
we drop shm_lock.

diffstat:

 sys/kern/sysv_shm.c |  17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diffs (42 lines):

diff -r 74e6cda6de7f -r eae14b7a7da0 sys/kern/sysv_shm.c
--- a/sys/kern/sysv_shm.c       Tue Sep 10 16:11:00 2019 +0000
+++ b/sys/kern/sysv_shm.c       Tue Sep 10 16:14:53 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysv_shm.c,v 1.135 2019/06/10 00:35:47 chs Exp $       */
+/*     $NetBSD: sysv_shm.c,v 1.135.2.1 2019/09/10 16:14:53 martin Exp $        */
 
 /*-
  * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.135 2019/06/10 00:35:47 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.135.2.1 2019/09/10 16:14:53 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sysv.h"
@@ -425,14 +425,19 @@
        shmseg->shm_lpid = p->p_pid;
        shmseg->shm_nattch++;
        shm_realloc_disable++;
+
+       /*
+        * Add a reference to the uvm object while we hold the
+        * shm_lock.
+        */
+       uobj = shmseg->_shm_internal;
+       uao_reference(uobj);
        mutex_exit(&shm_lock);
 
        /*
-        * Add a reference to the memory object, map it to the
-        * address space, and lock the memory, if needed.
+        * Drop the shm_lock to map it into the address space, and lock
+        * the memory, if needed (XXX where does this lock memory?).
         */
-       uobj = shmseg->_shm_internal;
-       uao_reference(uobj);
        error = uvm_map(&vm->vm_map, &attach_va, size, uobj, 0, 0,
            UVM_MAPFLAG(prot, prot, UVM_INH_SHARE, UVM_ADV_RANDOM, flags));
        if (error)



Home | Main Index | Thread Index | Old Index