Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Prevent panic or hangup in softint_disestablish(), ...



details:   https://anonhg.NetBSD.org/src/rev/78d27b8035da
branches:  trunk
changeset: 828700:78d27b8035da
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Dec 28 03:39:48 2017 +0000

description:
Prevent panic or hangup in softint_disestablish(), pserialize_perform() or
psref_target_destroy() while mp_online == false.

 See http://mail-index.netbsd.org/tech-kern/2017/12/25/msg022829.html

diffstat:

 sys/kern/kern_softint.c    |  11 +++++++----
 sys/kern/subr_pserialize.c |   9 +++++++--
 sys/kern/subr_psref.c      |  14 ++++++++++----
 3 files changed, 24 insertions(+), 10 deletions(-)

diffs (103 lines):

diff -r db3f99c32221 -r 78d27b8035da sys/kern/kern_softint.c
--- a/sys/kern/kern_softint.c   Wed Dec 27 21:34:11 2017 +0000
+++ b/sys/kern/kern_softint.c   Thu Dec 28 03:39:48 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_softint.c,v 1.44 2017/11/22 02:20:21 msaitoh Exp $        */
+/*     $NetBSD: kern_softint.c,v 1.45 2017/12/28 03:39:48 msaitoh Exp $        */
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -170,13 +170,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.44 2017/11/22 02:20:21 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.45 2017/12/28 03:39:48 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
 #include <sys/intr.h>
 #include <sys/ipi.h>
 #include <sys/mutex.h>
+#include <sys/kernel.h>
 #include <sys/kthread.h>
 #include <sys/evcnt.h>
 #include <sys/cpu.h>
@@ -430,8 +431,10 @@
         * it again.  So, we are only looking for handler records with
         * SOFTINT_ACTIVE already set.
         */
-       where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-       xc_wait(where);
+       if (__predict_true(mp_online)) {
+               where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
+               xc_wait(where);
+       }
 
        for (;;) {
                /* Collect flag values from each CPU. */
diff -r db3f99c32221 -r 78d27b8035da sys/kern/subr_pserialize.c
--- a/sys/kern/subr_pserialize.c        Wed Dec 27 21:34:11 2017 +0000
+++ b/sys/kern/subr_pserialize.c        Thu Dec 28 03:39:48 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pserialize.c,v 1.9 2017/11/21 08:49:14 ozaki-r Exp $      */
+/*     $NetBSD: subr_pserialize.c,v 1.10 2017/12/28 03:39:48 msaitoh Exp $     */
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.9 2017/11/21 08:49:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.10 2017/12/28 03:39:48 msaitoh Exp $");
 
 #include <sys/param.h>
 
@@ -157,6 +157,11 @@
        KASSERT(psz->psz_owner == NULL);
        KASSERT(ncpu > 0);
 
+       if (__predict_false(mp_online == false)) {
+               psz_ev_excl.ev_count++;
+               return;
+       }
+
        /*
         * Set up the object and put it onto the queue.  The lock
         * activity here provides the necessary memory barrier to
diff -r db3f99c32221 -r 78d27b8035da sys/kern/subr_psref.c
--- a/sys/kern/subr_psref.c     Wed Dec 27 21:34:11 2017 +0000
+++ b/sys/kern/subr_psref.c     Thu Dec 28 03:39:48 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_psref.c,v 1.9 2017/12/14 05:45:55 ozaki-r Exp $   */
+/*     $NetBSD: subr_psref.c,v 1.10 2017/12/28 03:39:48 msaitoh Exp $  */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.9 2017/12/14 05:45:55 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.10 2017/12/28 03:39:48 msaitoh Exp $");
 
 #include <sys/types.h>
 #include <sys/condvar.h>
@@ -429,8 +429,14 @@
                .ret = false,
        };
 
-       /* Ask all CPUs to say whether they hold a psref to the target.  */
-       xc_wait(xc_broadcast(0, &psreffed_p_xc, &P, NULL));
+       if (__predict_true(mp_online)) {
+               /*
+                * Ask all CPUs to say whether they hold a psref to the
+                * target.
+                */
+               xc_wait(xc_broadcast(0, &psreffed_p_xc, &P, NULL));
+       } else
+               psreffed_p_xc(&P, NULL);
 
        return P.ret;
 }



Home | Main Index | Thread Index | Old Index