netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net-gro: reset skb->pkt_type in napi_reuse_skb()
@ 2018-11-18  5:51 Eric Dumazet
  2018-11-18  5:55 ` Eric Dumazet
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2018-11-18  5:51 UTC (permalink / raw)
  To: David S . Miller; +Cc: netdev, Eric Dumazet, Eric Dumazet

eth_type_trans() assumes initial value for skb->pkt_type
is PACKET_HOST.

This is indeed the value right after a fresh skb allocation.

However, it is possible that GRO merged a packet with a different
value (like PACKET_OTHERHOST in case macvlan is used), so
we need to make sure napi->skb will have pkt_type set back to
PACKET_HOST.

Otherwise, valid packets might be dropped by the stack because
their pkt_type is not PACKET_HOST.

napi_reuse_skb() was added in commit 96e93eab2033 ("gro: Add
internal interfaces for VLAN"), but this bug always has
been there.

Fixes: 96e93eab2033 ("gro: Add internal interfaces for VLAN")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/dev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 0ffcbdd55fa9ee545c807f2ed3fc178830e3075a..689ff83af855660f8b9aaa0266b5e509cd0839cb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5655,6 +5655,11 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
 	skb->vlan_tci = 0;
 	skb->dev = napi->dev;
 	skb->skb_iif = 0;
+
+	/* eth_type_trans() assumes pkt_type is PACKET_HOST */
+	WARN_ON_ONCE(skb->pkt_type != PACKET_HOST);
+	skb->pkt_type = PACKET_HOST;
+
 	skb->encapsulation = 0;
 	skb_shinfo(skb)->gso_type = 0;
 	skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));
-- 
2.19.1.1215.g8438c0b245-goog

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

* Re: [PATCH net] net-gro: reset skb->pkt_type in napi_reuse_skb()
  2018-11-18  5:51 [PATCH net] net-gro: reset skb->pkt_type in napi_reuse_skb() Eric Dumazet
@ 2018-11-18  5:55 ` Eric Dumazet
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2018-11-18  5:55 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller; +Cc: netdev, Eric Dumazet



On 11/17/2018 09:51 PM, Eric Dumazet wrote:
> eth_type_trans() assumes initial value for skb->pkt_type
> is PACKET_HOST.
> 
> This is indeed the value right after a fresh skb allocation.
> 
> However, it is possible that GRO merged a packet with a different
> value (like PACKET_OTHERHOST in case macvlan is used), so
> we need to make sure napi->skb will have pkt_type set back to
> PACKET_HOST.
> 
> Otherwise, valid packets might be dropped by the stack because
> their pkt_type is not PACKET_HOST.
> 
> napi_reuse_skb() was added in commit 96e93eab2033 ("gro: Add
> internal interfaces for VLAN"), but this bug always has
> been there.
> 
> Fixes: 96e93eab2033 ("gro: Add internal interfaces for VLAN")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
>  net/core/dev.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 0ffcbdd55fa9ee545c807f2ed3fc178830e3075a..689ff83af855660f8b9aaa0266b5e509cd0839cb 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -5655,6 +5655,11 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
>  	skb->vlan_tci = 0;
>  	skb->dev = napi->dev;
>  	skb->skb_iif = 0;
> +
> +	/* eth_type_trans() assumes pkt_type is PACKET_HOST */

> +	WARN_ON_ONCE(skb->pkt_type != PACKET_HOST);

Oops sorry for this bit, I will send a v2 without it of course.


> +	skb->pkt_type = PACKET_HOST;
> +
>  	skb->encapsulation = 0;
>  	skb_shinfo(skb)->gso_type = 0;
>  	skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));
> 

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

end of thread, other threads:[~2018-11-18 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-18  5:51 [PATCH net] net-gro: reset skb->pkt_type in napi_reuse_skb() Eric Dumazet
2018-11-18  5:55 ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).