diff mbox series

[net-next,v5,10/11] tcp: clean ext on tx recycle

Message ID 20191219223434.19722-11-mathew.j.martineau@linux.intel.com
State Deferred, archived
Headers show
Series Multipath TCP: Prerequisites | expand

Commit Message

Mat Martineau Dec. 19, 2019, 10:34 p.m. UTC
From: Paolo Abeni <pabeni@redhat.com>

Otherwise we will find stray/unexpected/old extensions value on next
iteration.

On tcp_write_xmit() we can end-up splitting an already queued skb in two
parts, via tso_fragment(). The newly created skb can be allocated via
the tx cache and an upper layer will not be aware of it, so that upper
layer cannot set the ext properly.

Resetting the ext on recycle ensures that stale data is not propagated
in to packet headers or elsewhere.

An alternative would be add an additional hook in tso_fragment() or in
sk_stream_alloc_skb() to init the ext for upper layers that need it.

Co-developed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
 include/net/sock.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Eric Dumazet Dec. 20, 2019, 3:29 p.m. UTC | #1
On 12/19/19 2:34 PM, Mat Martineau wrote:
> From: Paolo Abeni <pabeni@redhat.com>
> 
> Otherwise we will find stray/unexpected/old extensions value on next
> iteration.
> 
> On tcp_write_xmit() we can end-up splitting an already queued skb in two
> parts, via tso_fragment(). The newly created skb can be allocated via
> the tx cache and an upper layer will not be aware of it, so that upper
> layer cannot set the ext properly.
> 
> Resetting the ext on recycle ensures that stale data is not propagated
> in to packet headers or elsewhere.
> 
> An alternative would be add an additional hook in tso_fragment() or in
> sk_stream_alloc_skb() to init the ext for upper layers that need it.
> 
> Co-developed-by: Florian Westphal <fw@strlen.de>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
> ---

Reviewed-by: Eric Dumazet <edumazet@google.com>
diff mbox series

Patch

diff --git a/include/net/sock.h b/include/net/sock.h
index b93cadba1a3b..23efed7f4e70 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1474,6 +1474,7 @@  static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
 	sk_mem_uncharge(sk, skb->truesize);
 	if (static_branch_unlikely(&tcp_tx_skb_cache_key) &&
 	    !sk->sk_tx_skb_cache && !skb_cloned(skb)) {
+		skb_ext_reset(skb);
 		skb_zcopy_clear(skb, true);
 		sk->sk_tx_skb_cache = skb;
 		return;