]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[SCTP]: Add bind hash locking to the migrate code
authorVlad Yasevich <vladislav.yasevich@hp.com>
Fri, 7 Dec 2007 06:50:27 +0000 (22:50 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 7 Dec 2007 09:07:45 +0000 (01:07 -0800)
SCTP accept code tries to add a newliy created socket
to a bind bucket without holding a lock.   On a really
busy system, that can causes slab corruptions.
Add a lock around this code.

Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/socket.c

index ff8bc95670edbfa6af9ece6d74d2dc656a9c3cba..9f5d7930f54d7187835a1565862ffb441772d5f0 100644 (file)
@@ -6325,6 +6325,7 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
        struct sctp_endpoint *newep = newsp->ep;
        struct sk_buff *skb, *tmp;
        struct sctp_ulpevent *event;
+       struct sctp_bind_hashbucket *head;
        int flags = 0;
 
        /* Migrate socket buffer sizes and all the socket level options to the
@@ -6342,10 +6343,15 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
        newsp->hmac = NULL;
 
        /* Hook this new socket in to the bind_hash list. */
+       head = &sctp_port_hashtable[sctp_phashfn(inet_sk(oldsk)->num)];
+       sctp_local_bh_disable();
+       sctp_spin_lock(&head->lock);
        pp = sctp_sk(oldsk)->bind_hash;
        sk_add_bind_node(newsk, &pp->owner);
        sctp_sk(newsk)->bind_hash = pp;
        inet_sk(newsk)->num = inet_sk(oldsk)->num;
+       sctp_spin_unlock(&head->lock);
+       sctp_local_bh_enable();
 
        /* Copy the bind_addr list from the original endpoint to the new
         * endpoint so that we can handle restarts properly