All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] tcp: cleanup sk_tx_skb_cache before reuse
@ 2019-03-29 19:46 Eric Dumazet
  2019-03-29 19:50 ` Soheil Hassas Yeganeh
  2019-03-29 20:17 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2019-03-29 19:46 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Eric Dumazet, Eric Dumazet, Soheil Hassas Yeganeh,
	Willem de Bruijn

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 <edumazet@google.com>
Cc: Soheil Hassas Yeganeh <soheil@google.com>
Cc: Willem de Bruijn <willemb@google.com>
---
 net/ipv4/tcp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 82bd707c03472f2cebb1a90d5f1c13acc821468f..603e770d59b3db96adca9602319d2f6970a56285 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tcp: cleanup sk_tx_skb_cache before reuse
  2019-03-29 19:46 [PATCH net-next] tcp: cleanup sk_tx_skb_cache before reuse Eric Dumazet
@ 2019-03-29 19:50 ` Soheil Hassas Yeganeh
  2019-03-29 20:17 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Soheil Hassas Yeganeh @ 2019-03-29 19:50 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S . Miller, netdev, Eric Dumazet, Willem de Bruijn

On Fri, Mar 29, 2019 at 3:46 PM Eric Dumazet <edumazet@google.com> wrote:
>
> 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 <edumazet@google.com>
> Cc: Soheil Hassas Yeganeh <soheil@google.com>
> Cc: Willem de Bruijn <willemb@google.com>

Acked-by: Soheil Hassas Yeganeh <soheil@google.com>

Nice catch! Thank you!

> ---
>  net/ipv4/tcp.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 82bd707c03472f2cebb1a90d5f1c13acc821468f..603e770d59b3db96adca9602319d2f6970a56285 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tcp: cleanup sk_tx_skb_cache before reuse
  2019-03-29 19:46 [PATCH net-next] tcp: cleanup sk_tx_skb_cache before reuse Eric Dumazet
  2019-03-29 19:50 ` Soheil Hassas Yeganeh
@ 2019-03-29 20:17 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-03-29 20:17 UTC (permalink / raw)
  To: edumazet; +Cc: netdev, eric.dumazet, soheil, willemb

From: Eric Dumazet <edumazet@google.com>
Date: Fri, 29 Mar 2019 12:46:17 -0700

> 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 <edumazet@google.com>

Applied, thanks Eric.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-01 18:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-29 19:46 [PATCH net-next] tcp: cleanup sk_tx_skb_cache before reuse Eric Dumazet
2019-03-29 19:50 ` Soheil Hassas Yeganeh
2019-03-29 20:17 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.