kernel-ark/net
Herbert Xu 134af34632 [DCCP]: Fix sock_orphan dead lock
Calling sock_orphan inside bh_lock_sock in dccp_close can lead to dead
locks.  For example, the inet_diag code holds sk_callback_lock without
disabling BH.  If an inbound packet arrives during that admittedly tiny
window, it will cause a dead lock on bh_lock_sock.  Another possible
path would be through sock_wfree if the network device driver frees the
tx skb in process context with BH enabled.

We can fix this by moving sock_orphan out of bh_lock_sock.

The tricky bit is to work out when we need to destroy the socket
ourselves and when it has already been destroyed by someone else.

By moving sock_orphan before the release_sock we can solve this
problem.  This is because as long as we own the socket lock its
state cannot change.

So we simply record the socket state before the release_sock
and then check the state again after we regain the socket lock.
If the socket state has transitioned to DCCP_CLOSED in the time being,
we know that the socket has been destroyed.  Otherwise the socket is
still ours to keep.

This problem was discoverd by Ingo Molnar using his lock validator.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-05-05 17:09:13 -07:00
..
802
8021q
appletalk
atm
ax25 [AX.25]: Eleminate HZ from AX.25 kernel interfaces 2006-05-03 23:27:16 -07:00
bluetooth
bridge [BRIDGE]: keep track of received multicast packets 2006-05-05 17:07:13 -07:00
core Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6 2006-04-20 15:26:25 -07:00
dccp [DCCP]: Fix sock_orphan dead lock 2006-05-05 17:09:13 -07:00
decnet [DECNET]: Fix level1 router hello 2006-05-03 23:36:23 -07:00
econet
ethernet
ieee80211 [PATCH] softmac: fix SIOCSIWAP 2006-04-24 15:20:23 -04:00
ipv4 [TCP]: Fix sock_orphan dead lock 2006-05-03 23:31:35 -07:00
ipv6 [IPV6]: Fix race in route selection. 2006-04-29 18:33:22 -07:00
ipx
irda
key
lapb
llc [LLC]: Use pskb_trim_rcsum() in llc_fixup_skb(). 2006-04-19 15:37:13 -07:00
netfilter [NETFILTER]: x_tables: don't use __copy_{from,to}_user on unchecked memory in compat layer 2006-05-03 23:20:27 -07:00
netlink Merge branch 'audit.b10' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit-current 2006-05-01 21:43:05 -07:00
netrom [NETROM]: Eleminate HZ from NET/ROM kernel interfaces 2006-05-03 23:27:47 -07:00
packet
rose [ROSE]: Eleminate HZ from ROSE kernel interfaces 2006-05-03 23:28:20 -07:00
rxrpc
sched [PKT_SCHED] netem: fix loss 2006-04-29 18:33:12 -07:00
sctp [SCTP]: Fix state table entries for chunks received in CLOSED state. 2006-05-05 17:05:23 -07:00
sunrpc
tipc
unix
wanrouter
x25 [X25]: fix for spinlock recurse and spinlock lockup with timer handler 2006-04-29 18:33:11 -07:00
xfrm [XFRM]: fix incorrect xfrm_policy_afinfo_lock use 2006-04-29 18:33:21 -07:00
compat.c
Kconfig
Makefile
nonet.c
socket.c [PATCH] sockaddr patch 2006-05-01 06:06:10 -04:00
sysctl_net.c
TUNABLE