🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12089

Re: [PATCH net v3 3/8] tun: clear stale skb->protocol of NAPI frags skbs

#12089
From: Eric Dumazet
Date: Fri, 06 Nov 2026 08:49
59 lines
11372 bytes
Le ven. 6 nov. 2026 à 05:21, Willem de Bruijn
<willemdebruijn.kernel@gmail.com> a écrit :
>
> Eric Dumazet wrote:
> > With IFF_NAPI_FRAGS, tun_napi_alloc_frags() gets its skb from
> > napi_get_frags(). If GRO merged the previous frame with
> > GRO_MERGED_FREE, that skb was recycled by napi_reuse_skb(), which does
> > not reset skb->protocol set by napi_frags_skb() for the previous frame.
> >
> > On the IFF_TAP path, tun_get_user() calls tun_vnet_hdr_tnl_to_skb()
> > before eth_type_trans(), so the virtio header checks see the protocol
> > of the previous frame: the outer protocol check of UDP tunnel GSO
> > packets rejects a valid frame when the two ethertypes differ, and
> > GSO packets without VIRTIO_NET_HDR_F_NEEDS_CSUM are dissected with
> > the wrong protocol.
> >
> > This needs GRO to hold packets across writes, for example with
> > napi_defer_hard_irqs and gro_flush_timeout set on the device.
> >
> > Clear skb->protocol for IFF_TAP frames, as for skbs allocated by
> > tun_alloc_skb(). eth_type_trans() sets it right after.
> >
> > Fixes: 90e33d459407 ("tun: enable napi_gro_frags() for TUN/TAP driver")
> > Reported-by: Sashiko <sashiko-bot@kernel.org>
> > Closes: https://lore.kernel.org/netdev/179386753589.488856.11455181721004759454@kernel.org/
> > Signed-off-by: Eric Dumazet <edumazet@kernel.org>
>
> Reviewed-by: Willem de Bruijn <willemb@google.com>
>
> > ---
> >  drivers/net/tun.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> > index 3920b3dff1e8..6b648f21018c 100644
> > --- a/drivers/net/tun.c
> > +++ b/drivers/net/tun.c
> > @@ -1941,6 +1941,11 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
> >                       goto drop;
> >               }
> >               skb_set_network_header(skb, ETH_HLEN);
> > +             /* A NAPI frags skb recycled by napi_reuse_skb() keeps the
> > +              * protocol of a previous frame. eth_type_trans() sets it
> > +              * below, the virtio header checks must not see a stale one.
> > +              */
> > +             skb->protocol = 0;
>
> This resets it for all IFF_TAP.
>
> Would it make sense to do this in tun_napi_alloc_frags if it is only
> needed for IFF_NAPI_FRAGS?

Yes, other skbs come from tun_alloc_skb() or build_skb() with a zero
protocol. Done in v4, where I kept your Reviewed-by.
Technical Details
Message-ID: <CAL4WiiqrXe6XehCt+SiR-PzpXzYK71U+rP_vBhJ09ub3TZnjcQ@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357851-linux-kernel-netdev=dewy.ru
References: <20261105115715.1466924-1-edumazet@kernel.org> <20261105115715.1466924-4-edumazet@kernel.org> <willemdebruijn.kernel.1afc96da83d57@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357851-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 3/8] tun: clear stale skb->protocol of NAPI frags skbs
Date: Fri, 6 Nov 2026 09:49:06 +0100
Organization: Usenet Network
Message-ID: <CAL4WiiqrXe6XehCt+SiR-PzpXzYK71U+rP_vBhJ09ub3TZnjcQ@mail.gmail.com>
References: <20261105115715.1466924-1-edumazet@kernel.org> <20261105115715.1466924-4-edumazet@kernel.org>
 <willemdebruijn.kernel.1afc96da83d57@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3831448"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0Hk9h4ZzEvKycuypqLnJmaPCOQc= sha256:gfnkaw/ogftAvRduJ9pqCF7fV+bACKZ8tKxsiP6iBJM=
	sha1:roFhtYWRA7fDvkV9lEZxmLNHMi0= sha256:cIFf83PIc0UmrMDoHA4s/rWEMe/4DS44Ltqqw0SUdng=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 3FB551131C3; Fri,  6 Nov 2026 11:53:44 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 2lHBfPF3X1vu;
	Fri,  6 Nov 2026 11:53:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-357851-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8BAD51131AE; Fri,  6 Nov 2026 11:53:32 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id A18383245C; Fri,  6 Nov 2026 08:49:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793954960;
	b=FdHGNfFl3JYxU2y4Npgkdo38bmMP5L2tiWwNevvePQ2jfsD0uwaVLfy5x6QCGa8udfR6
	 lJY10uylPbvQuCwFr5fRJTWnBdzrHJuAVTYmhUWOds3EOAsiAL6s5H53L8pCjnQXO5AEv
	 X2ZRCBetkWQ0uUxAOTqQmcDcqMDmh6zJObplUd1X690ZjL3cNlPER6cd7gjNHEKx4Vh6a
	 g8b2UStgr3e3y/9FlnDiwSZJ32D+1+q9SCOjPUPsVEDjdgEqlIho1DaJqltLi8Ypz3c40
	 kSeFi7YQlsQwRuyku0EiVwtWIU/U4uz7K6BHiTT5eEyTMIYfWrwDGz8u/6ABVfsiZfA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793954960;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Gm-Message-State:X-Received:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=DgXP7zZI1FlaPaSSGpM+hJxyXMjUNEAftizK0rzrvB8=;
	b=NCqL54C46koOVlNP+mY/Et7jdki/hEQh4dax/3Uj+XpGgBF86kOnpBerCG+n3hsPqqs6
	 1Wndj+yM3vOTpZ+iDNWfaxcxyNteK9HPirJatXgECJ6uudc4imqFy6iYVkOq7TYNCTnDL
	 1IpB1BO/Xdk1Ho0yVBwdUpqJ0v8Xw59r81+1GiFJKZg8B/KnD7iBUNuqEOjakS/7zFZYg
	 1Ag8HXP6V1F119bJYAxhvSHsFcS1sCiU/GWupCRDWKdtbxLL67KSvLFhwparWyKLtAdIJ
	 KJajZZbTjyJ7PIHjn0QdfKzH72w9JDyx3J5usq8mAZO94zfjFymQJRBIygg0OGXDHRA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DZPHm5ui;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C950606A326;
	Fri,  6 Nov 2026 08:49:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DZPHm5ui
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793954959;
	b=EWNgbH+OmTyv+O5nQCc9xXFcYflgHWWXAzFVTQn4iG6TYOSBBMomPsduv/MdquZwNzGE
	 MVZTWvLn+M5pE12NX86rUsCH4PBtFXxgQFbZa4h4yRO7doeehuL7GXEu4wqg2//iil8TB
	 gGC+3Uqw4Ylv6GB6Zgz5YYNPYZH7OETI8vLu72Co9KtuAnrQMH6Lon7pk30kLdTx5uIWa
	 f64v7Bgk0kcEWKOg6zX4LEL596T3fzQOS68LbMlST7DJah/Cf4Nb4O/YzxbvPledIA/Zh
	 uqNcAVe8u4t7OLaYugHJS41Nl4wNTjl9EuuD4wUNYbnYb17UDWuX7gBnXFJx/oiY68Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793954959;
	h=Received:DKIM-Signature:Received:X-Gm-Message-State:X-Received:
	 MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=DgXP7zZI1FlaPaSSGpM+hJxyXMjUNEAftizK0rzrvB8=;
	b=H6LNgue8t/3R7or8GgkJCMi1GfdOdglX3LJek5tUPEroBhicEpak/1VUddv0fKEEvU9l
	 KWDkdulmDVlKkjfiThVUS/tk3LkoxsxIJZ6uLclp5RL1feJt6vun6zkPxPCoTjXNoY7eZ
	 4nRWAHzRHkTU3VFgG3U6BvILQ9TDmjVEDgrXNi4yIvKtGu0PtBaUibJzgvfUx35rGlN1P
	 W2j9vpyXXhuA8QW7U9Ypb9jGhVOJX1h+7+I5jh7gC0fdjXShWbjnrKWRkaItiISjwhX/Y
	 MOPI8/jysM+aE9IefgD7SJ0Szd7ddWIk9vUJtrKqe8jB+9T1mR1KNbWyo35OzMGx0Tw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DZPHm5ui;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FB82606A329
	for <netdev@vger.kernel.org>; Fri,  6 Nov 2026 08:49:19 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9DE51F0089F
	for <netdev@vger.kernel.org>; Fri,  6 Nov 2026 08:49:18 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793954958;
	bh=DgXP7zZI1FlaPaSSGpM+hJxyXMjUNEAftizK0rzrvB8=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=DZPHm5uiZBwE4Dfn527zSL0DaEhuyn+7lYoex9PMjTVa/E9heISQGnqAO53JbYTSu
	 5IIoAb66VFlweRXSpAOgGkQNhEII9pDPwB8xbqaLTILlrIPqBKIMCUX9VbKtcpLwd1
	 XwH6DXpupBu+qRJRa9YpSzlBUyCZVtk6HQilDURNwrrAYWNjS9el15DhxbLxZobTsp
	 BbvY6yqKGsHPp8H33bZTlZvdc4t7jglDugg8OCdwwFnA4eT7oY/zCN4XcU3/nh92Lh
	 i3LWjpinjkskuD3oryRLFnxNUXe+ggNjQNLxu6+HbGYYO+Lr6/MmIcat3IJ/BjVl17
	 rGa+RWj8Sf0Uw==
X-Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-4932b13c4ccso193962fac.3
        for <netdev@vger.kernel.org>; Fri, 06 Nov 2026 00:49:18 -0800 (PST)
X-Gm-Message-State: APuU4Z+ekmyxIBmC9EWKgaOX8FbCYtN50XDLSEnjxlSfBe2c3K7DhbHq
	AITvM62Jn9zW7aiW0CVtgvFBSXffIk/+Cc5Lsc6pxjzwMKpPerb7GCsKeeNBNXHd0GHmpXH8I6z
	VyFlSkGvc9JQKroHvc/PLMmOFVLtielQ=
X-Received: by 2002:a05:6870:b3c3:b0:4a8:6aa4:5ac7 with SMTP id
 586e51a60fabf-4ad98e47a9emr1170796fac.45.1793954958065; Fri, 06 Nov 2026
 00:49:18 -0800 (PST)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <willemdebruijn.kernel.1afc96da83d57@gmail.com>
X-Gmail-Original-Message-ID: <CAL4WiiqrXe6XehCt+SiR-PzpXzYK71U+rP_vBhJ09ub3TZnjcQ@mail.gmail.com>
X-Gm-Features: AclHuK-7ZZim4zJUAqt1vFqkkEBh1Sez_DrWsXKs9fMK90nqYIlPwYCa_geKNP4
X-Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, 
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, 
	Willem de Bruijn <willemb@google.com>, "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowangio@gmail.com>, 
	Eugenio Pérez <eperezma@redhat.com>, 
	Hassan Sultan <hassansultan@google.com>, virtualization@lists.linux.dev