Patch "net: fix socket refcounting in skb_complete_wifi_ack()" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
net: fix socket refcounting in skb_complete_wifi_ack()
to the 4.9-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:
net-fix-socket-refcounting-in-skb_complete_wifi_ack.patch
and it can be found in the queue-4.9 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 Mar 18 22:03:25 CST 2017
From: Eric Dumazet <[email protected]>
Date: Fri, 3 Mar 2017 21:01:02 -0800
Subject: net: fix socket refcounting in skb_complete_wifi_ack()
From: Eric Dumazet <[email protected]>
[ Upstream commit dd4f10722aeb10f4f582948839f066bebe44e5fb ]
TX skbs do not necessarily hold a reference on skb->sk->sk_refcnt By the time TX completion happens, sk_refcnt might be already 0.
sock_hold()/sock_put() would then corrupt critical state, like sk_wmem_alloc.
--- net/core/skbuff.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
net/core/skbuff.c +8 -7
@@ -3871,7 +3871,7 @@ void skb_complete_wifi_ack(struct sk_buf {struct sock *sk = skb->sk;struct sock_exterr_skb *serr; -int err; +int err =1 ; skb->wifi_acked_valid =1 ; skb->wifi_acked = acked;
@@ -3881,14 +3881,15 @@ void skb_complete_wifi_ack(struct sk_buf serr->ee.ee_errno =ENOMSG ; serr->ee.ee_origin =SO_EE_ORIGIN_TXSTATUS ; -/* take a reference to prevent skb_orphan() from freeing the socket */ -sock_hold (sk); - - err =sock_queue_err_skb (sk, skb); +/* Take a reference to prevent skb_orphan() from freeing the socket, +* but only if the socket refcount is not zero. +*/ +if (likely (atomic_inc_not_zero (&sk->sk_refcnt))) { + err =sock_queue_err_skb (sk, skb); +sock_put (sk); + }if (err)kfree_skb (skb); - -sock_put (sk); }EXPORT_SYMBOL_GPL (skb_complete_wifi_ack);
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/tcp-fix-various-issues-for-sockets-morphing-to-listen-state.patch queue-4.9/tcp-dccp-block-bh-for-syn-processing.patch queue-4.9/dccp-fix-use-after-free-in-dccp_feat_activate_values.patch queue-4.9/net-fix-socket-refcounting-in-skb_complete_tx_timestamp.patch queue-4.9/net-net_enable_timestamp-can-be-called-from-irq-contexts.patch queue-4.9/dccp-unlock-sock-before-calling-sk_free.patch queue-4.9/net-don-t-call-strlen-on-the-user-buffer-in-packet_bind_spkt.patch queue-4.9/net-fix-socket-refcounting-in-skb_complete_wifi_ack.patch queue-4.9/ipv6-orphan-skbs-in-reassembly-unit.patch