Article View: linux.kernel.netdev
Article #11670[PATCH net v3 3/8] tun: clear stale skb->protocol of NAPI frags skbs
From: Eric Dumazet
Date: Thu, 05 Nov 2026 11:57
Date: Thu, 05 Nov 2026 11:57
45 lines
9499 bytes
9499 bytes
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>
---
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;
break;
}
--
2.53.0
Technical Details
Message-ID:
<20261105115715.1466924-4-edumazet@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357288-linux-kernel-netdev=dewy.ruReferences:
<20261105115715.1466924-1-edumazet@kernel.org>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-357288-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH net v3 3/8] tun: clear stale skb->protocol of NAPI frags skbs Date: Thu, 5 Nov 2026 12:57:10 +0100 Organization: Usenet Network Message-ID: <20261105115715.1466924-4-edumazet@kernel.org> References: <20261105115715.1466924-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3634773"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:KpI5Vk5wTMjLIIhlSNv5Qj3Rue8= sha256:943xU22OCblXPQR8tqHKGd5DabUwUs+86L1PBmJAAy8= sha1:DKhhVNR1DUAZPKexS7qLmHyiUPc= sha256:ngku1FZauxw8qZpzS+TULCsgu3CMld4dX6t9Ah3izE4= 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 259AA112F6F; Thu, 5 Nov 2026 15:25:37 +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 zveCKunW5EF7; Thu, 5 Nov 2026 15:25:33 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-357288-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 3C518112F66; Thu, 5 Nov 2026 15:25:24 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id C7EAB33E40; Thu, 5 Nov 2026 11:57:49 +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=1793879850; b=HPT+zVaVeukOUoiub6xxpglcpnJ/3/rbUoqtGihTLQJ+SX/scW+wJyhyeY6bMoiSV6HC eo2UtJs09f13DxQDOf1we34MvllXU1Fe++pAqP5FuNzT3C4f/mn3/tBma7x2ak42xGs9Y Z0zgUd0sTRCpbdFwbPDtsL7/oV49A3sn8DhWd6RTYU89l+99vYJcvvbk5EJ3puCJiDWWx JUwbdoS+3N21Cwd3/dxCCzoBj4geC6h0VpdjmkbeMvrTv3I8uuNf1Llxg0+tlPzBPlD6j RgNVt3x+nM/LfjVZ0e22DaceF3jQUedr7Pa09QFkkgsdFGn0lGcQjUtU2XJjoh1JkyA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793879850; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=Lpa4x7IMkI0pAmvLfxMZgiuZ7+FSjz5ACO8N7GXOsnc=; b=sjlwo6WLBIqu9JOI62z5nQRCZgn07eIiwwVyLjM3Fhb7kU3ifcHJ9pF07WlqN0VXNVwv iI5GeObuQzHZbRTaRMTr2lEhGm8znDHhaw97vvs/948Ll5hVbZHEdW92XFpqQF+PGmVDA BeghxrtcHc8MXWCma+NWbCpFSQ8XPF428dYJjGfKOnfzHPxgHBHKrc/tPK1H9/u8pkWrK Ug6hSctrTQjE4q2WIx79EH1gK/Xq4Y+X4kgFO7HmVMn9q2a5Mp+vdWsXH2IMx7zQLAf3e m8XLuqaeWm1VOb8u46Sb95SWgNM4sKUV7yBh0gIuxG1Vs5OBEQKd6zHdjRfsxDdQS4w== 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=hHKKOxtF; 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 67DB2606D832; Thu, 5 Nov 2026 11:57:30 +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=hHKKOxtF 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=1793879849; b=e6Slgi+ZNjLpLvr6pBJEVrvpF930WNu1PClWdpEuC9oT6Rzjg0SkSvIGy8H/J4HbUW5O 6l5IbxsyxisG17a2i5IdH98sj32YE1GNtFu+ZLZP90xNNf62C+UnfGYZ9/w8jxs5YCV+f VyGV9ZCtnG9NHLLcY0NP0JnYKJ5h6p05uaVRgmLn7nyQj7x2fyB0FFXQTPtsL75DU/sPc d2y9OW0mRMJmcXzQFkyOxjlFfKFeVN7soKgXANQC61sHA2OYQkDvSN60l/HuiEl8pT0bC Rr59bNbNrXx2MXMU7t4tpKWSmRoqn1jEbP756nCjSBob7nBRsmklpZt2HMqpnkg2qRQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793879849; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=Lpa4x7IMkI0pAmvLfxMZgiuZ7+FSjz5ACO8N7GXOsnc=; b=Ihv4e73IBERcwO2V4C5M2rAH4CaWryefkTjfWa4fJfr0BvxA9Bx75sd5DMmH2YLySU8/ ZY1TwKzyluoTY8hFJKeF5mdgfFV0s8kK4fxzLRafK1kKmDy/QB++724738Q2s76RcJbr4 TnflY8JCPF3SplJpLXLPUg5KOCrCaSi+e9nyr1FAA73hzqpbO+g7J4U6DTmJt9D6Qvs++ nW7HOpy2lLgmwSTpjyOb1HZJd8hK9W35y1dwE1kXdAi9CD/qR+GpWP0FMAQpKYoS8ClyW p79Ky+DX1eT9QT4d5MvYSOpK/g52JkKGF4VfrLpYoCKoIlT1ClRCWUe5jSX92LN7jKw== 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=hHKKOxtF; 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 4C9C0606D801; Thu, 5 Nov 2026 11:57:29 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AEF31F00A15; Thu, 5 Nov 2026 11:57:26 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793879849; bh=Lpa4x7IMkI0pAmvLfxMZgiuZ7+FSjz5ACO8N7GXOsnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hHKKOxtFlWgDXqCg7HPSBhZblipLs99GZooDHgQPGVSXmlGHBrB84XvlhW2Ht8JY+ c2nY3FQI1c5xfBHg9BdBf23QzkslS55wesYV+UMZTaBkcXaTT0gOOQ62RRcrMqCJHP ADNKkmDePPVKysQsV5fFQ+SxAh+ETj/n0lEOR9pkaQM4h915oSYuiWY8PFBrL4wcC7 ULvByd9N1vE7KW81qFK+3zYlnzIkKQ3ytYL9IGUV2DrVMiBgwrouDA7f4jZt56AWWx 5l9+Kp9Dirg1Q3HmBrpPOitZnuDba3NLZzwL/Iv7oe/EFvLj8fKcoJSu+Hcx+OuSdI By57OlPfi2n/A== X-Cc: Eric Dumazet <edumazet@kernel.org>, 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 X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261105115715.1466924-1-edumazet@kernel.org> 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