Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/xen/xen fix locking against myself panic in xennet_...



details:   https://anonhg.NetBSD.org/src/rev/983654f360fe
branches:  trunk
changeset: 1009090:983654f360fe
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Apr 12 13:55:06 2020 +0000

description:
fix locking against myself panic in xennet_stop() on 'ifconfig xennet0 down'

xennet_stop() is called with IFNET already held

diffstat:

 sys/arch/xen/xen/if_xennet_xenbus.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r e26ba9d926c8 -r 983654f360fe sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c       Sun Apr 12 13:37:12 2020 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c       Sun Apr 12 13:55:06 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: if_xennet_xenbus.c,v 1.112 2020/04/11 11:01:12 jdolecek Exp $      */
+/*      $NetBSD: if_xennet_xenbus.c,v 1.113 2020/04/12 13:55:06 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.112 2020/04/11 11:01:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.113 2020/04/12 13:55:06 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -411,11 +411,13 @@
        DPRINTF(("%s: xennet_xenbus_detach\n", device_xname(self)));
 
        /* stop interface */
+       IFNET_LOCK(ifp);
        xennet_stop(ifp, 1);
        if (sc->sc_ih != NULL) {
                xen_intr_disestablish(sc->sc_ih);
                sc->sc_ih = NULL;
        }
+       IFNET_UNLOCK(ifp);
 
        /* collect any outstanding TX responses */
        mutex_enter(&sc->sc_tx_lock);
@@ -1146,9 +1148,9 @@
 {
        struct xennet_xenbus_softc *sc = ifp->if_softc;
 
-       IFNET_LOCK(ifp);
+       KASSERT(IFNET_LOCKED(ifp));
+
        ifp->if_flags &= ~IFF_RUNNING;
-       IFNET_UNLOCK(ifp);
        hypervisor_mask_event(sc->sc_evtchn);
 }
 



Home | Main Index | Thread Index | Old Index