tcp: do not recycle cloned skbs
Subsystems (4)
PATCH 1/1 tcp: do not recycle cloned skbs
It is illegal to change arbitrary fields in skb_shared_info if the skb is cloned.
Before calling skb_zcopy_clear() we need to ensure this rule, therefore we need to move the test from sk_stream_alloc_skb() to sk_wmem_free_skb()
--- include/net/sock.h | 2 +- net/ipv4/tcp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/net/sock.h +1 -1
@@ -1473,7 +1473,7 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)sock_set_flag (sk,SOCK_QUEUE_SHRUNK ); sk->sk_wmem_queued -= skb->truesize;sk_mem_uncharge (sk, skb->truesize); -if (!sk->sk_tx_skb_cache) { +if (!sk->sk_tx_skb_cache && !skb_cloned (skb)) {skb_zcopy_clear (skb, true); sk->sk_tx_skb_cache = skb;return ;
net/ipv4/tcp.c +1 -1
@@ -855,7 +855,7 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,if (likely (!size)) { skb = sk->sk_tx_skb_cache; -if (skb && !skb_cloned (skb)) { +if (skb) { skb->truesize =SKB_TRUESIZE (skb_end_offset (skb)); sk->sk_tx_skb_cache =NULL ;pskb_trim (skb,0 );
Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Wed, 15 May 2019 09:10:15 -0700
Quoted 10 lines
It is illegal to change arbitrary fields in
skb_shared_infoif the skb is cloned.Before calling
skb_zcopy_clear()we need to ensure this rule, therefore we need to move the test fromsk_stream_alloc_skb()tosk_wmem_free_skb()Fixes 4f661542a402 ("tcp: fix zerocopy and notsent_lowat issues")Signed-off-by Eric Dumazet <[email protected]>Diagnosed-by Willem de Bruijn <[email protected]>
Applied and queued up for -stable.
Quoted 11 lines · David Miller
From: Eric Dumazet <[email protected]>
Date: Wed, 15 May 2019 09:10:15 -0700Quoted 7 lines
It is illegal to change arbitrary fields in
skb_shared_infoif the skb is cloned.Before calling
skb_zcopy_clear()we need to ensure this rule, therefore we need to move the test fromsk_stream_alloc_skb()tosk_wmem_free_skb()
Quoted 5 lines
Quoted 3 lines
Fixes 4f661542a402 ("tcp: fix zerocopy and notsent_lowat issues")Signed-off-by Eric Dumazet <[email protected]>Diagnosed-by Willem de Bruijn <[email protected]>Applied and queued up for -stable.
Note the patch targets current net tree, but does not need to be backported to older kernel versions
(4f661542a402 is only in upcoming 5.2)
Thanks !
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Wed, 15 May 2019 09:26:54 -0700
Quoted 16 lines · David Miller
Quoted 15 lines
From: Eric Dumazet <[email protected]>
Date: Wed, 15 May 2019 09:10:15 -0700Quoted 10 lines
It is illegal to change arbitrary fields in
skb_shared_infoif the skb is cloned.Before calling
skb_zcopy_clear()we need to ensure this rule, therefore we need to move the test fromsk_stream_alloc_skb()tosk_wmem_free_skb()Fixes 4f661542a402 ("tcp: fix zerocopy and notsent_lowat issues")Signed-off-by Eric Dumazet <[email protected]>Diagnosed-by Willem de Bruijn <[email protected]>
Quoted 5 lines
Quoted 1 line
Applied and queued up for -stable.
Note the patch targets current net tree, but does not need to be backported to older kernel versions
(4f661542a402is only in upcoming 5.2)
Doesn't it fix a fix for something in 5.0?
Quoted 20 lines · David Miller
From: Eric Dumazet <[email protected]>
Date: Wed, 15 May 2019 09:26:54 -0700Quoted 16 lines · David Miller
Quoted 15 lines
From: Eric Dumazet <[email protected]>
Date: Wed, 15 May 2019 09:10:15 -0700Quoted 10 lines
It is illegal to change arbitrary fields in
skb_shared_infoif the skb is cloned.Before calling
skb_zcopy_clear()we need to ensure this rule, therefore we need to move the test fromsk_stream_alloc_skb()tosk_wmem_free_skb()Fixes 4f661542a402 ("tcp: fix zerocopy and notsent_lowat issues")Signed-off-by Eric Dumazet <[email protected]>Diagnosed-by Willem de Bruijn <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Applied and queued up for -stable.
Note the patch targets current net tree, but does not need to be backported to older kernel versions
(4f661542a402is only in upcoming 5.2)Doesn't it fix a fix for something in 5.0?
Hmm no, the whole thing is new for 5.2 only.
commit 472c2e07eef045145bc1493cc94a01c87140780a
Author: Eric Dumazet <[email protected]> Date: Fri Mar 22 08:56:39 2019 -0700
tcp: add one skb cache for tx