Phonet: listening socket lock protects the connected socket list
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>
Wed, 26 May 2010 00:44:44 +0000 (00:44 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 29 May 2010 07:18:50 +0000 (00:18 -0700)
The accept()'d socket need to be unhashed while the (listen()'ing)
socket lock is held. This fixes a race condition that could lead to an
OOPS.

Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/phonet/pep.c

index 7b048a35ca5837368e4ace101a57564eacbb51fc..94d72e85a475ae094d14f8df5f4f54a936f0db15 100644 (file)
@@ -1045,12 +1045,12 @@ static void pep_sock_unhash(struct sock *sk)
        lock_sock(sk);
        if ((1 << sk->sk_state) & ~(TCPF_CLOSE|TCPF_LISTEN)) {
                skparent = pn->listener;
-               sk_del_node_init(sk);
                release_sock(sk);
 
-               sk = skparent;
                pn = pep_sk(skparent);
-               lock_sock(sk);
+               lock_sock(skparent);
+               sk_del_node_init(sk);
+               sk = skparent;
        }
        /* Unhash a listening sock only when it is closed
         * and all of its active connected pipes are closed. */