Article View: linux.kernel.netdev
Article #14207[PATCH net v6 2/3] tun: clear stale skb->protocol of NAPI frags skbs
From: Eric Dumazet
Date: Tue, 10 Nov 2026 21:36
Date: Tue, 10 Nov 2026 21:36
48 lines
9674 bytes
9674 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.
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:
GSO packets without VIRTIO_NET_HDR_F_NEEDS_CSUM are dissected with the
wrong protocol. A following change checks the outer protocol of UDP
tunnel GSO packets, which would then reject a valid frame when the two
ethertypes differ.
This needs GRO to hold packets across writes, and IFF_NAPI_FRAGS needs
CAP_NET_ADMIN.
Clear skb->protocol in tun_napi_alloc_frags(), like skbs allocated
by tun_alloc_skb() or build_skb(). eth_type_trans() sets it later.
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/
Suggested-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
drivers/net/tun.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 3b292bce4438..d1fcb25ab026 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1500,6 +1500,12 @@ static struct sk_buff *tun_napi_alloc_frags(struct tun_file *tfile,
if (!skb)
return ERR_PTR(-ENOMEM);
+ /* An skb recycled by napi_reuse_skb() keeps the protocol of a
+ * previous frame. eth_type_trans() sets it after the virtio
+ * header checks, which must not see a stale one.
+ */
+ skb->protocol = 0;
+
linear = iov_iter_single_seg_count(it);
err = __skb_grow(skb, linear);
if (err)
--
2.53.0
Technical Details
Message-ID:
<20261110213628.3476051-3-edumazet@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360637-linux-kernel-netdev=dewy.ruReferences:
<20261110213628.3476051-1-edumazet@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360637-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH net v6 2/3] tun: clear stale skb->protocol of NAPI frags skbs Date: Tue, 10 Nov 2026 22:36:27 +0100 Organization: Usenet Network Message-ID: <20261110213628.3476051-3-edumazet@kernel.org> References: <20261110213628.3476051-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="707851"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:57F3Y09eLEvX70WUX0H+OkR6PNE= sha256:wpvp8jxbjCm1Deqc0YwaiFqYgDr9HqNT7KK5HaCZu4A= sha1:uTxifVCwVAzCbEgyFR0qfOIiVSE= sha256:HTJTX/gXML/rm9E1KRX1eInPePXivhj6A0A4RPFAyd0= 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 EC925113D4B; Wed, 11 Nov 2026 00:37:15 +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 QbpMSsXsf3h6; Wed, 11 Nov 2026 00:37:12 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-360637-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 46874113D46; Wed, 11 Nov 2026 00:37:03 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 3ED4C62727; Tue, 10 Nov 2026 21:36:53 +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=1794346612; b=a8jYNRopG/IrXgSfbLXeowStg86HqV7I358uqGrDsux5ZPqZSJwBp35C4TAv7XWsnl0l 66L1D50epWdn0Gg0/mDhDnAKrIRU0Sgl6kfwxCKz+iUQTc7g7r0H16G4bzjBhSNBnZpuS 4X0O9nVdV8jX3wnYwd2KgIudBqqD46bWtlsHEQXh7x6X63R1+YS3j5fthpzsYCya7OWyD 1EiK7PWfRNxXra6tjgbKDN6zjCspAW8oDtA3BXwIFMDSzh+ClCs6cQfTe1A4jj6dW12RP xSMAWOY/1cCqAfunWqGiJitjJMS/NhcyZ3i5kPHFkmwXtOZ2PMsa/v8cMfH+DoSS1Jg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794346612; 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=ri7mT9GeXsX4XZreU1Xu63qBi5/LRjSnYOgyacuU+mg=; b=FX8S8B6C7oMnp/kfRdtaDG86JiEXDYoFjr2JsorShxGmvDd58NGf6EwbGh+bFu8vBB5X eRDJLKrufI0Id6+wF9nOTFKxXocRGvlg3WyBoXfnRStmbpk5BIzhU9+3vBUpsOhMASEXJ IPhaQ6K+wRBpVLyhcDkOzt9QQ8nmkCEpIbEn3RI1BnkBU4l3fywlwnbTvzgvIZUlxnsaB dPmOeEDIArizbLhA50GmcsT3/n+ktkWLoMw29dlIpUobdZir3b4aznHu/ugShzM24M3z4 hA+QjRHgB9dcWK2eUuVf/hSXba/ACzNvt4OXkOlDnr9ZKsluALePCb4FtPRiuF9axUw== 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=WX2fik0d; 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 847CB606A32E; Tue, 10 Nov 2026 21:36:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WX2fik0d 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=1794346602; b=MIyePpgBGYkLdnF5nyaGWP57B6uibqGvBhlIIhKWEycgPxtD3wAxGEEnhKwRob7z5+GQ idJsghbrrQQ0x5D3QeHAoTzTjU4b2Q9FglcpzbFK7+DJ9AHs2KpyWSSUNKHdiv+1TmijN SR7dlqyITju2q4gG+cJIZFkjJDLUfbmBsQc8/Ox6FmyxASGZMPXAnzuz9uAfNuj+mpF7C vXqcswE3Nw9NTePDcVugncprHBGSmuhlr6JpVNonr2vvSdzM2EqMFVFGSBBarAVatFZhg UC3Yru5/byjY+rpdfNO78jkWmgzobcfyGGEoIuXzPRppt69m+qMMIw2Jv09KaFkY9RA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794346602; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=ri7mT9GeXsX4XZreU1Xu63qBi5/LRjSnYOgyacuU+mg=; b=i+YjrPSddnd26cIzi4B8gZSzBdF3b84iQK511eDoj3KKs+2mr2gI2FV2PtxfStXjpqOh Bv6oznFiVPJt6dM32Zvt3wuG/+HzbjsKzkdW3O8QVLGsw9kix0QsxwanLc0bxAgiNIPwT CYMfQn3zmBeQpAdG/56qm2L2AKwQt/WK0LuTH6lDtf5F1Vr0ph671ryEPUoh7/YqW8g+i 3UCK4SmOD1Jag0yHkUTKZUtE4de089ooS/cLmzJUeHUazyUvBBDKHyrrmHJJVy9q7Qgsi xvJFXQNKzi24+wqewOyuGMFeusgVEBH0OtBu/we1zRCL3/p9+Rzd+7QMs7IjDP/5HiQ== 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=WX2fik0d; 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 D2272606A31C; Tue, 10 Nov 2026 21:36:41 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C888D1F0089F; Tue, 10 Nov 2026 21:36:38 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794346601; bh=ri7mT9GeXsX4XZreU1Xu63qBi5/LRjSnYOgyacuU+mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WX2fik0dGtHFTNtxwL+e0nAAlgemQs7CZIjjWPoMy44XKiqJLOAsuamj1MLUpqFIz VDbabtlnPi+57tR9ffATurg15SSj2fSUOF3XLrStBS+FhyKcViKqSRgmJNUNXjzv00 nGOhu4cw2MeiWWjX5hlckTZ7xLBXp8c5TcBCD7MWOOwHgaSMSyCLoYydPW3/OgyCYu R7OJS6GlsPqN6rQ78Lxe5Lh9C8OcMTGxXU9S2j7tMRF+dDDCuZ4RBd7wLpFmkJTcON fe5vIxsWc4dfddk3WEIKNdrVduJu6JMsbF5U6wnrK8T8rI28kfiXma95XLJpv6qyad GGXr1EW9KccRQ== X-Cc: Willem de Bruijn <willemb@google.com>, Simon Horman <horms@kernel.org>, edumazet@kernel.org, "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowangio@gmail.com>, Xuan Zhuo <xuanzhuo@linux.alibaba.com>, Eugenio PΓ©rez <eperezma@redhat.com>, Hassan Sultan <hassansultan@google.com>, virtualization@lists.linux.dev, Sashiko <sashiko-bot@kernel.org> X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261110213628.3476051-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