[SCTP]: Add bind hash locking to the migrate code

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>

authored by Vlad Yasevich and committed by David S. Miller f26f7c48 56c99d04

+6
+6
net/sctp/socket.c
··· 6325 6325 struct sctp_endpoint *newep = newsp->ep; 6326 6326 struct sk_buff *skb, *tmp; 6327 6327 struct sctp_ulpevent *event; 6328 + struct sctp_bind_hashbucket *head; 6328 6329 int flags = 0; 6329 6330 6330 6331 /* Migrate socket buffer sizes and all the socket level options to the ··· 6343 6342 newsp->hmac = NULL; 6344 6343 6345 6344 /* Hook this new socket in to the bind_hash list. */ 6345 + head = &sctp_port_hashtable[sctp_phashfn(inet_sk(oldsk)->num)]; 6346 + sctp_local_bh_disable(); 6347 + sctp_spin_lock(&head->lock); 6346 6348 pp = sctp_sk(oldsk)->bind_hash; 6347 6349 sk_add_bind_node(newsk, &pp->owner); 6348 6350 sctp_sk(newsk)->bind_hash = pp; 6349 6351 inet_sk(newsk)->num = inet_sk(oldsk)->num; 6352 + sctp_spin_unlock(&head->lock); 6353 + sctp_local_bh_enable(); 6350 6354 6351 6355 /* Copy the bind_addr list from the original endpoint to the new 6352 6356 * endpoint so that we can handle restarts properly