linux/net/dccp
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
..
ccids [DCCP] options: Make dccp_insert_options & friends yell on error 2006-03-20 22:32:06 -08:00
Kconfig [DCCP] ipv6: Add missing ipv6 control socket 2006-03-20 22:00:37 -08:00
Makefile [DCCP]: Move the IPv4 specific bits from proto.c to ipv4.c 2006-03-20 21:25:11 -08:00
ackvec.c [DCCP] options: Make dccp_insert_options & friends yell on error 2006-03-20 22:32:06 -08:00
ackvec.h [DCCP] ackvec: Introduce ack vector records 2006-03-20 17:19:55 -08:00
ccid.c [DCCP] CCID: Improve CCID infrastructure 2006-03-20 19:21:44 -08:00
ccid.h [DCCP] options: Make dccp_insert_options & friends yell on error 2006-03-20 22:32:06 -08:00
dccp.h [DCCP] minisock: Rename struct dccp_options to struct dccp_minisock 2006-03-20 22:50:58 -08:00
diag.c [DCCP] minisock: Rename struct dccp_options to struct dccp_minisock 2006-03-20 22:50:58 -08:00
feat.c [DCCP]: Use NULL for pointers, comfort sparse. 2006-03-29 13:58:25 -08:00
feat.h [DCCP] feat: Pass dccp_minisock ptr where only the minisock is used 2006-03-20 22:51:53 -08:00
input.c [DCCP] minisock: Rename struct dccp_options to struct dccp_minisock 2006-03-20 22:50:58 -08:00
ipv4.c [DCCP]: Fix leak in net/dccp/ipv4.c 2006-04-11 17:21:06 -07:00
ipv6.c [NET]: Identation & other cleanups related to compat_[gs]etsockopt cset 2006-03-20 22:48:35 -08:00
ipv6.h [DCCP]: Introduce DCCPv6 2006-01-03 13:10:52 -08:00
minisocks.c [DCCP] minisock: Rename struct dccp_options to struct dccp_minisock 2006-03-20 22:50:58 -08:00
options.c [DCCP] minisock: Rename struct dccp_options to struct dccp_minisock 2006-03-20 22:50:58 -08:00
output.c [DCCP] options: Make dccp_insert_options & friends yell on error 2006-03-20 22:32:06 -08:00
proto.c [DCCP]: Fix sock_orphan dead lock 2006-05-05 17:09:13 -07:00
sysctl.c [DCCP] feat: Introduce sysctls for the default features 2006-03-20 19:25:02 -08:00
timer.c [DCCP]: Generalize dccp_v4_send_reset 2006-03-20 19:25:24 -08:00