linux-uconsole/net
Vlad Yasevich 6552df6df2 sctp: Fix a race between ICMP protocol unreachable and connect()
commit 50b5d6ad63 upstream.

ICMP protocol unreachable handling completely disregarded
the fact that the user may have locked the socket.  It proceeded
to destroy the association, even though the user may have
held the lock and had a ref on the association.  This resulted
in the following:

Attempt to release alive inet socket f6afcc00

=========================
[ BUG: held lock freed! ]
-------------------------
somenu/2672 is freeing memory f6afcc00-f6afcfff, with a lock still held
there!
 (sk_lock-AF_INET){+.+.+.}, at: [<c122098a>] sctp_connect+0x13/0x4c
1 lock held by somenu/2672:
 #0:  (sk_lock-AF_INET){+.+.+.}, at: [<c122098a>] sctp_connect+0x13/0x4c

stack backtrace:
Pid: 2672, comm: somenu Not tainted 2.6.32-telco #55
Call Trace:
 [<c1232266>] ? printk+0xf/0x11
 [<c1038553>] debug_check_no_locks_freed+0xce/0xff
 [<c10620b4>] kmem_cache_free+0x21/0x66
 [<c1185f25>] __sk_free+0x9d/0xab
 [<c1185f9c>] sk_free+0x1c/0x1e
 [<c1216e38>] sctp_association_put+0x32/0x89
 [<c1220865>] __sctp_connect+0x36d/0x3f4
 [<c122098a>] ? sctp_connect+0x13/0x4c
 [<c102d073>] ? autoremove_wake_function+0x0/0x33
 [<c12209a8>] sctp_connect+0x31/0x4c
 [<c11d1e80>] inet_dgram_connect+0x4b/0x55
 [<c11834fa>] sys_connect+0x54/0x71
 [<c103a3a2>] ? lock_release_non_nested+0x88/0x239
 [<c1054026>] ? might_fault+0x42/0x7c
 [<c1054026>] ? might_fault+0x42/0x7c
 [<c11847ab>] sys_socketcall+0x6d/0x178
 [<c10da994>] ? trace_hardirqs_on_thunk+0xc/0x10
 [<c1002959>] syscall_call+0x7/0xb

This was because the sctp_wait_for_connect() would aqcure the socket
lock and then proceed to release the last reference count on the
association, thus cause the fully destruction path to finish freeing
the socket.

The simplest solution is to start a very short timer in case the socket
is owned by user.  When the timer expires, we can do some verification
and be able to do the release properly.

Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-01-07 14:43:18 -08:00
..
9p 9p: strlen() doesn't count the terminator 2010-08-10 10:20:39 -07:00
802 net: remove COMPAT_NET_DEV_OPS 2009-05-25 01:53:53 -07:00
8021q vlan: Fix register_vlan_dev() error path 2009-11-17 06:45:04 -08:00
appletalk Have atalk_route_packet() return NET_RX_SUCCESS not NET_XMIT_SUCCESS 2009-09-14 17:02:47 -07:00
atm net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
ax25 ax25: netrom: rose: Fix timer oopses 2010-02-09 04:50:56 -08:00
bluetooth Bluetooth: Fix kernel crash on L2CAP stress tests 2010-04-01 15:58:55 -07:00
bridge bridge: Clear INET control block of SKBs passed into ip_fragment(). 2010-09-26 17:21:19 -07:00
can can-bcm: fix minor heap overflow 2010-12-09 13:27:10 -08:00
core net: release dst entry while cache-hot for GSO case too 2011-01-07 14:43:14 -08:00
dcb net: fix double skb free in dcbnl 2009-09-26 20:16:15 -07:00
dccp dccp_probe: Fix module load dependencies between dccp and dccp_probe 2010-05-12 14:57:11 -07:00
decnet DECnet: don't leak uninitialized stack byte 2010-12-09 13:27:03 -08:00
dsa netdev: convert pseudo-devices to netdev_tx_t 2009-09-01 01:13:07 -07:00
econet econet: fix CVE-2010-3850 2010-12-09 13:27:12 -08:00
ethernet net: remove COMPAT_NET_DEV_OPS 2009-05-25 01:53:53 -07:00
ieee802154 net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
ipv4 Limit sysctl_tcp_mem and sysctl_udp_mem initializers to prevent integer overflows. 2010-12-09 13:27:06 -08:00
ipv6 ip: fix truesize mismatch in ip fragmentation 2010-10-28 21:44:08 -07:00
ipx net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
irda irda: Fix heap memory corruption in iriap.c 2010-12-09 13:26:32 -08:00
iucv net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
key net: file_operations should be const 2009-09-02 01:03:53 -07:00
lapb net: remove NET_RX_BAD and NET_RX_CN* defines 2009-07-05 19:15:35 -07:00
llc net/llc: make opt unsigned in llc_ui_setsockopt() 2010-09-26 17:21:24 -07:00
mac80211 mac80211: fix supported rates IE if AP doesn't give us it's rates 2010-08-02 10:21:27 -07:00
netfilter netfilter: nf_conntrack: allow nf_ct_alloc_hashtable() to get highmem pages 2010-12-09 13:26:51 -08:00
netlabel Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2009-07-30 19:22:43 -07:00
netlink netlink: fix compat recvmsg 2010-08-26 16:41:55 -07:00
netrom ax25: netrom: rose: Fix timer oopses 2010-02-09 04:50:56 -08:00
packet af_packet: Don't use skb after dev_queue_xmit() 2010-02-09 04:50:56 -08:00
phonet Phonet: disable network namespace support 2010-10-28 21:44:17 -07:00
rds rds: Integer overflow in RDS cmsg handling 2010-12-09 13:27:12 -08:00
rfkill Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6 2009-11-23 14:01:47 -08:00
rose rose: Fix signedness issues wrt. digi count. 2010-10-28 21:44:10 -07:00
rxrpc net: Make setsockopt() optlen be unsigned. 2009-09-30 16:12:20 -07:00
sched net sched: fix some kernel memory leaks 2010-12-09 13:27:14 -08:00
sctp sctp: Fix a race between ICMP protocol unreachable and connect() 2011-01-07 14:43:18 -08:00
sunrpc sunrpc: prevent use-after-free on clearing XPT_BUSY 2011-01-07 14:43:05 -08:00
tipc tipc: Fix oops on send prior to entering networked mode (v3) 2010-07-05 11:11:16 -07:00
unix UNIX: Do not loop forever at unix_autobind(). 2010-09-26 17:21:21 -07:00
wanrouter headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
wimax wimax: fix warning caused by not checking retval of rfkill_set_hw_state() 2009-06-11 11:12:48 -07:00
wireless wext: fix potential private ioctl memory content leak 2010-10-28 21:44:02 -07:00
x25 x25: Prevent crashing when parsing bad X.25 facilities 2010-12-09 13:27:10 -08:00
xfrm net: file_operations should be const 2009-09-02 01:03:53 -07:00
compat.c net: Limit socket I/O iovec total length to INT_MAX. 2010-12-09 13:27:13 -08:00
Kconfig net/compat/wext: send different messages to compat tasks 2009-07-15 08:53:39 -07:00
Makefile net: remove redundant sched/ in net/Makefile 2009-07-12 20:11:14 -07:00
nonet.c
socket.c net: Truncate recvfrom and sendto length to INT_MAX. 2010-12-09 13:27:12 -08:00
sysctl_net.c
TUNABLE