]> git.baikalelectronics.ru Git - kernel.git/commit
net: sock_copy() fixes
authorEric Dumazet <eric.dumazet@gmail.com>
Wed, 15 Jul 2009 23:13:10 +0000 (23:13 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 17 Jul 2009 01:05:26 +0000 (18:05 -0700)
commit13ff4d196381a966fb11a48e6f3ed15719b55ca1
treef4b9959e9ca5e5b8bdb6301663a15e0f67d4c68c
parent026e8d14fd8ca71b28a723f446044c4829d5e0c0
net: sock_copy() fixes

Commit a18b4d64a8130fe673ced15742f787e6cea9a8f4
(net: sk_prot_alloc() should not blindly overwrite memory)
took care of not zeroing whole new socket at allocation time.

sock_copy() is another spot where we should be very careful.
We should not set refcnt to a non null value, until
we are sure other fields are correctly setup, or
a lockless reader could catch this socket by mistake,
while not fully (re)initialized.

This patch puts sk_node & sk_refcnt to the very beginning
of struct sock to ease sock_copy() & sk_prot_alloc() job.

We add appropriate smp_wmb() before sk_refcnt initializations
to match our RCU requirements (changes to sock keys should
be committed to memory before sk_refcnt setting)

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sock.h
net/core/sock.c