network - Protect soreceive() from backend
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 14 Sep 2010 01:40:22 +0000 (18:40 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 14 Sep 2010 01:40:22 +0000 (18:40 -0700)
* Somehow I missed the token required in soreceive() to protect it from
  the backend.

sys/kern/uipc_socket.c

index aa6b113..4ec07d3 100644 (file)
@@ -869,6 +869,11 @@ bad:
        if ((so->so_state & SS_ISCONFIRMING) && resid)
                so_pru_rcvd(so, 0);
 
+       /*
+        * The token interlocks against the protocol thread while
+        * ssb_lock is a blocking lock against other userland entities.
+        */
+       lwkt_gettoken(&so->so_rcv.ssb_token);
 restart:
        error = ssb_lock(&so->so_rcv, SBLOCKWAIT(flags));
        if (error)
@@ -1152,6 +1157,7 @@ dontblock:
 release:
        ssb_unlock(&so->so_rcv);
 done:
+       lwkt_reltoken(&so->so_rcv.ssb_token);
        if (free_chain)
                m_freem(free_chain);
        return (error);