Patch "inet: fix races with reqsk timers" has been added to the 4.1-stable tree
Subsystems (4)
This is a note to let you know that I've just added the patch titled
inet: fix races with reqsk timers
to the 4.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
inet-fix-races-with-reqsk-timers.patch
and it can be found in the queue-4.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Sat Sep 26 11:13:07 PDT 2015
From: Eric Dumazet <[email protected]>
Date: Mon, 10 Aug 2015 09:09:13 -0700
Subject: inet: fix races with reqsk timers
From: Eric Dumazet <[email protected]>
[ Upstream commit 2235f2ac75fd2501c251b0b699a9632e80239a6d ]
reqsk_queue_destroy() and reqsk_queue_unlink() should use del_timer_sync() instead of del_timer() before calling reqsk_put(), otherwise we could free a req still used by another cpu.
But before doing so, reqsk_queue_destroy() must release syn_wait_lock spinlock or risk a dead lock, as reqsk_timer_handler() might need to take this same spinlock from reqsk_queue_unlink() (called from inet_csk_reqsk_queue_drop())
--- net/core/request_sock.c | 8 +++++++- net/ipv4/inet_connection_sock.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-)
net/core/request_sock.c +7 -1
@@ -103,10 +103,16 @@ void reqsk_queue_destroy(struct request_spin_lock_bh (&queue->syn_wait_lock);while ((req = lopt->syn_table[i]) !=NULL ) { lopt->syn_table[i] = req->dl_next; +/* Because of following del_timer_sync(), +* we must release the spinlock here +* or risk a dead lock. +*/ +spin_unlock_bh (&queue->syn_wait_lock);atomic_inc (&lopt->qlen_dec); -if (del_timer (&req->rsk_timer)) +if (del_timer_sync (&req->rsk_timer))reqsk_put (req);reqsk_put (req); +spin_lock_bh (&queue->syn_wait_lock); }spin_unlock_bh (&queue->syn_wait_lock); }
net/ipv4/inet_connection_sock.c +1 -1
@@ -584,7 +584,7 @@ static bool reqsk_queue_unlink(struct re }spin_unlock (&queue->syn_wait_lock); -if (del_timer (&req->rsk_timer)) +if (del_timer_sync (&req->rsk_timer))reqsk_put (req);return found; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.1/udp-fix-dst-races-with-multicast-early-demux.patch queue-4.1/fq_codel-fix-a-use-after-free.patch queue-4.1/inet-fix-possible-request-socket-leak.patch queue-4.1/ipv6-lock-socket-in-ip6_datagram_connect.patch queue-4.1/net-fix-skb-csum-races-when-peeking.patch queue-4.1/inet-fix-races-with-reqsk-timers.patch queue-4.1/net-graceful-exit-from-netif_alloc_netdev_queues.patch queue-4.1/bridge-fix-potential-crash-in-__netdev_pick_tx.patch queue-4.1/inet-frags-fix-defragmented-packet-s-ip-header-for-af_packet.patch