tcp: cleanup sk_tx_skb_cache before reuse
Subsystems (3)
PATCH 1/1 tcp: cleanup sk_tx_skb_cache before reuse
TCP stack relies on the fact that a freshly allocated skb has skb->cb[] and skb_shinfo(skb)->tx_flags cleared.
When recycling tx skb, we must ensure these fields are cleared.
Fixes 472c2e07eef0 ("tcp: add one skb cache for tx")
Signed-off-by Eric Dumazet <[email protected]>
Cc Soheil Hassas Yeganeh <[email protected]>
Cc Willem de Bruijn <[email protected]>
--- net/ipv4/tcp.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/tcp.c +2 -0
@@ -872,6 +872,8 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp, sk->sk_tx_skb_cache =NULL ;pskb_trim (skb,0 );INIT_LIST_HEAD (&skb->tcp_tsorted_anchor); +skb_shinfo (skb)->tx_flags =0 ; +memset (TCP_SKB_CB (skb),0 ,sizeof (struct tcp_skb_cb ));return skb; } }
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
Quoted 10 lines · Eric Dumazet
TCP stack relies on the fact that a freshly allocated skb has skb->cb[] and skb_shinfo(skb)->tx_flags cleared.
When recycling tx skb, we must ensure these fields are cleared.
Fixes 472c2e07eef0 ("tcp: add one skb cache for tx")Signed-off-by Eric Dumazet <[email protected]>Cc Soheil Hassas Yeganeh <[email protected]>Cc Willem de Bruijn <[email protected]>
Nice catch! Thank you!
Quoted 20 lines
--- net/ipv4/tcp.c | 2 ++ 1 file changed, 2 insertions(+)net/ipv4/tcp.c +2
-1@@ -872,6 +872,8 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp, sk->sk_tx_skb_cache =NULL ;pskb_trim (skb,0 );INIT_LIST_HEAD (&skb->tcp_tsorted_anchor); +skb_shinfo (skb)->tx_flags =0 ; +memset (TCP_SKB_CB (skb),0 ,sizeof (struct tcp_skb_cb ));return skb; } } --2.21.0.392.gf8f6787159e-goog
From: Eric Dumazet <[email protected]>
Date: Fri, 29 Mar 2019 12:46:17 -0700
Quoted 7 lines
TCP stack relies on the fact that a freshly allocated skb has skb->cb[] and skb_shinfo(skb)->tx_flags cleared.
When recycling tx skb, we must ensure these fields are cleared.
Fixes 472c2e07eef0 ("tcp: add one skb cache for tx")Signed-off-by Eric Dumazet <[email protected]>
Applied, thanks Eric.