net: Fix sk reference counting in ip_push_pending_frames and ip6_push_pending_frames
Subsystems (3)
PATCH 1/1 net: Fix sk reference counting in ip_push_pending_frames and ip6_push_pending_frames
Commit 2b85a34e911bf483c27cfdd124aeb1605145dc80 "net: No more expensive sock_hold()/sock_put() on each tx" used sk_wmem_alloc rather than the struct sock reference count to track in-flight transmit-path packets. However, it missed the __sock_put() calls in ip_push_pending_frames() and ip6_push_pending_frames(). This results in too-small reference counts when UDP or RAW sockets are used to send more than one MTU of data. This in turn could lead to struct sock being freed and reused while it is still part of an active socket.
A wide variety of socket symptoms may be fixed by this patch. It also fixes one cause of WARN_ON's in sk_del_node_init() and sk_nulls_del_node_init_rcu().
--- net/ipv4/ip_output.c | 1 - net/ipv6/ip6_output.c | 1 - 2 files changed, 0 insertions(+), 2 deletions(-)
net/ipv4/ip_output.c +0 -1
@@ -1243,7 +1243,6 @@ int ip_push_pending_frames(struct sock *sk) skb->len += tmp_skb->len; skb->data_len += tmp_skb->len; skb->truesize += tmp_skb->truesize; -__sock_put (tmp_skb->sk); tmp_skb->destructor =NULL ; tmp_skb->sk =NULL ; }
net/ipv6/ip6_output.c +0 -1
@@ -1484,7 +1484,6 @@ int ip6_push_pending_frames(struct sock *sk) skb->len += tmp_skb->len; skb->data_len += tmp_skb->len; skb->truesize += tmp_skb->truesize; -__sock_put (tmp_skb->sk); tmp_skb->destructor =NULL ; tmp_skb->sk =NULL ; }
Signature · 1 line
1.5.4.3
Quoted 8 lines · John Dykstra
Commit
2b85a34e911bf483c27cfdd124aeb1605145dc80"net: No more expensive sock_hold()/sock_put() on each tx" usedsk_wmem_allocrather than the struct sock reference count to track in-flight transmit-path packets. However, it missed the__sock_put()calls inip_push_pending_frames()andip6_push_pending_frames(). This results in too-small reference counts when UDP or RAW sockets are used to send more than one MTU of data. This in turn could lead to struct sock being freed and reused while it is still part of an active socket.
Quoted 4 lines
A wide variety of socket symptoms may be fixed by this patch. It also fixes one cause of WARN_ON's in
sk_del_node_init()andsk_nulls_del_node_init_rcu().Signed-off-by John Dykstra <[email protected]>
Nice, but are you aware same patch was already posted, and is waiting for David approval ?
http://patchwork.ozlabs.org/patch/29618/
Quoted 29 lines
--- net/ipv4/ip_output.c | 1 - net/ipv6/ip6_output.c | 1 - 2 files changed, 0 insertions(+), 2 deletions(-)net/ipv4/ip_output.c +0
-1@@ -1243,7 +1243,6 @@ int ip_push_pending_frames(struct sock *sk) skb->len += tmp_skb->len; skb->data_len += tmp_skb->len; skb->truesize += tmp_skb->truesize; -__sock_put (tmp_skb->sk); tmp_skb->destructor =NULL ; tmp_skb->sk =NULL ; }net/ipv6/ip6_output.c +0
-1@@ -1484,7 +1484,6 @@ int ip6_push_pending_frames(struct sock *sk) skb->len += tmp_skb->len; skb->data_len += tmp_skb->len; skb->truesize += tmp_skb->truesize; -__sock_put (tmp_skb->sk); tmp_skb->destructor =NULL ; tmp_skb->sk =NULL ; }
Quoted 19 lines · Eric Dumazet
Quoted 1 line · John Dykstra
Commit
2b85a34e911bf483c27cfdd124aeb1605145dc80"net: No moreexpensive
Quoted 1 line
sock_hold()/sock_put() on each tx" used
sk_wmem_allocrather thanthe struct sock reference
Quoted 1 line
count to track in-flight transmit-path packets. However, it missed
the
__sock_put()callsQuoted 1 line
in
ip_push_pending_frames()andip6_push_pending_frames(). Thisresults in too-small
Quoted 1 line
reference counts when UDP or RAW sockets are used to send more than
one MTU of data. This
Quoted 1 line
in turn could lead to struct sock being freed and reused while it is
still part of an
Quoted 3 lines
active socket.
A wide variety of socket symptoms may be fixed by this patch. It
also fixes one cause
Quoted 2 lines
of WARN_ON's in
sk_del_node_init()andsk_nulls_del_node_init_rcu().
Quoted 7 lines
Quoted 1 line
Signed-off-by John Dykstra <[email protected]>Nice, but are you aware same patch was already posted, and is waiting for David
approval ?
<sigh> No, I wasn't. It took me a while to track down where the reference counts were going wrong, and during that time I wasn't tracking netdev traffic.
At least it's fixed.
-- John