πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13303

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

#13303
From: Eric Dumazet
Date: Mon, 09 Nov 2026 16:35
47 lines
9655 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:
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, 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 3920b3dff1e8..9aca5056f7c5 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: <20261109163507.3102091-4-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-359441-linux-kernel-netdev=dewy.ru
References: <20261109163507.3102091-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-359441-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v5 3/3] tun: clear stale skb->protocol of NAPI frags skbs
Date: Mon,  9 Nov 2026 17:35:07 +0100
Organization: Usenet Network
Message-ID: <20261109163507.3102091-4-edumazet@kernel.org>
References: <20261109163507.3102091-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="401335"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:P7hkj//Mih6OOunFcRiAvjVaVF0= sha256:dauHetkF2ZbP+q90nyCpljk3RfQKEJg8IS4Kc3OdFvg=
	sha1:v263/xbsHOYt4s4Iqbe7xY8o8Xw= sha256:e5DMk0r+5G4UBRbho5hHKAuf0AJJGk/1nI2D0USUUm0=
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 533FF113889; Mon,  9 Nov 2026 19:38:50 +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 sVbBXCQbrhwK;
	Mon,  9 Nov 2026 19:38:46 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-359441-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 8E235113886; Mon,  9 Nov 2026 19:38:38 +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 BC265276DB; Mon,  9 Nov 2026 16:35:37 +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=1794242132;
	b=usEGEwaKnfsCnxQ4KMUW7kZSmgMCIFutdMEaCEjM5BdHoKH6qbN8yd21UIhpo3O1zBnD
	 o8cnKzT1EwhvpvWWAz3HJRMUeDUI8Jf+66klZAjutyVoaoJkyckpeGaOlNHvQxG9ND6VM
	 JvGJgu9/92C4wmXwdlIfD3CeZG3vEUzAVJivHm5kIB6+vrnWXZ6hq5cHz1mB+xM5VBUkP
	 6TDmDwxtnPOwNY0Qo7QWc9it50L40AmoR4wTVNfv4KB504ne5XCQ7tivA/zdB9yY2/By5
	 Tn//J37hc5VwYo+fjkeDpr93j6h3FQ7tGBCYsR6ExUKTlpUDEJdi5kJf3aAE8l2dlhA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794242132;
	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=43PEyzcC+jmO9SuRFxvHoqt9FvZx25sEYcqX+V5QNzU=;
	b=n+nH0cOqL1l2KWAT7LKvgRwmzz7YvZfZHRF8c3if4W9tjcGLCjO5e2UYL5mtj4ygiSq/
	 rXJDfY7rBPqgwxMBxs7ZmeQ8vYk8FMLXy5oBwNR8zPOirFGJ1mi/2Vt5e0nNapQq1HW5D
	 CBCVSnOb0AV0EFkRrOtR7XrNf6vjgOnMRk56+rQ8kG7IPREOpfSoOrcAiKcHC/7r9Qzs0
	 9qXqEdvLRgPdvUGwud1kPxTpYn03nIr0w+RLB+T5firXpQf0wezkhsodfeU70N9Ldt2Kx
	 1sIgGP/3uLbNfwtYOJLk+rNrIpTnmtbQUpwdhVu2ZF0DnI+B1Z3wEJ2bTmO2y5rTuUg==
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=mSxUxtFl;
	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 E27C8606A326;
	Mon,  9 Nov 2026 16:35:31 +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=mSxUxtFl
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=1794242125;
	b=2Ph9T7NP05oeKsFjbuXqiW/ov0LyBHmNjs6yQCoYOqziYqNamCorlOGfxFnJK4/p7m8O
	 Mqnk0JiJE0U5754R6r59U/p8RpKik+ZS80fxx7BiIoxLzJlbvYT+WJTDx+0h+eQ8WgcOz
	 r+ZEYfY+FqSL3xCdfRk6VIWZuGg4aFDrWw2/jSdDeTQGWnveeon+fd7d9+SaGQV0y4m/C
	 rVtMlTfCby6+qWqe9X1Zy+1WX3BXVUDrD0iFsEWiCrzYHCoKYxG/lkziIN00wXtNo3/S/
	 YjBmSILb2VRzZmXq7DRSYpY8U9YQmuxNJj27vSWGQ1jC0AtYZ8dph6Yqja7EhzgFa2A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794242125;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=43PEyzcC+jmO9SuRFxvHoqt9FvZx25sEYcqX+V5QNzU=;
	b=nEXolEEAvwugKDwefaaQ3rKRKkxtvntZHwkLmTRs6y3vLJmedFEJc0mMu3E3e7Nx9eRp
	 hz6DzJ3PZnNPair+asDjnDyhyno0aEmVdb3gIC6LBLfBnos7YCK60z7Dt/4AOoYQDNhoJ
	 zpOgarAfsw4fLExtoDRAmTXnhz+rZAlhoQe4+DTuRu/71A1hf0zOAqw0HmDPUkeZWqpzM
	 2vdiMPlh+cQexueK/Z0cfgISKHpEpKesPDaXX9KTqgYZTDpGdVyf2jLFsbDBGJdf5o5o9
	 v8qT6+lbj/pSI8PD7ZDjw7eUr9pFQl2LJSead26pxsqRfqtXM9k+91ODN/aJ1nXkoow==
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=mSxUxtFl;
	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 8C68B606A325;
	Mon,  9 Nov 2026 16:35:25 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00A221F0089F;
	Mon,  9 Nov 2026 16:35:21 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794242125;
	bh=43PEyzcC+jmO9SuRFxvHoqt9FvZx25sEYcqX+V5QNzU=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=mSxUxtFlT+1Lwo3RkI73K+J30SCw7SihejKDGpZF8zPjFCOqvZGO1v8YiNeCTPyQQ
	 JY51nNJlMzD1s+/ryvBaihv5tFuRiTlZvOTjMitDtApjl2RbIMta8R1T6qAdAIN610
	 w0VpnmNsU/nv6Nll/qcutT4DAhd7+nN2glNO/u0lJhPyqufUYVBAYyfxy2ibcjaH0J
	 LB42cZsQgyoM8yzAJ1+WMYr5MorS1j5dZ68fkh37hSkZdw0+tHaFsEUu7QVcMUueou
	 HUDzPrDMb9eNR3MG5rf82YXkmFqsO9vaT4Ylb800SSsqYoBqH7bsPu2TMMiEwkcRFv
	 S2U3YUsSF5+ng==
X-Cc: Simon Horman <horms@kernel.org>,
	Eric Dumazet <edumazet@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	"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: <20261109163507.3102091-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