kernel - Fix reentrant serialization in if_tun
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 22 Aug 2010 01:47:29 +0000 (18:47 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 22 Aug 2010 01:47:29 +0000 (18:47 -0700)
* Fix an issue where a KNOTE() is called while the serializer is held,
  resulting in nested serialization calls.

sys/net/tun/if_tun.c

index 8a87a66..59e7812 100644 (file)
@@ -398,7 +398,9 @@ tunoutput_serialized(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
                if (tp->tun_flags & TUN_ASYNC && tp->tun_sigio)
                        pgsigio(tp->tun_sigio, SIGIO, 0);
                rel_mplock();
+               ifnet_deserialize_all(ifp);
                KNOTE(&tp->tun_rkq.ki_note, 0);
+               ifnet_serialize_all(ifp);
        }
        return (error);
 }
@@ -790,6 +792,8 @@ tunstart(struct ifnet *ifp)
                }
                if (tp->tun_flags & TUN_ASYNC && tp->tun_sigio)
                        pgsigio(tp->tun_sigio, SIGIO, 0);
+               ifnet_deserialize_tx(ifp);
                KNOTE(&tp->tun_rkq.ki_note, 0);
+               ifnet_serialize_tx(ifp);
        }
 }