Article View: linux.kernel.netdev
Article #12124[PATCH net v4 2/2] tun: clear stale skb->protocol of NAPI frags skbs
From: Eric Dumazet
Date: Fri, 06 Nov 2026 09:53
Date: Fri, 06 Nov 2026 09:53
47 lines
9600 bytes
9600 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:
<20261106095340.2113683-3-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-357905-linux-kernel-netdev=dewy.ruReferences:
<20261106095340.2113683-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-357905-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH net v4 2/2] tun: clear stale skb->protocol of NAPI frags skbs Date: Fri, 6 Nov 2026 10:53:40 +0100 Organization: Usenet Network Message-ID: <20261106095340.2113683-3-edumazet@kernel.org> References: <20261106095340.2113683-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3842048"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:u5ECFExMNfpKHIzJmppLjlXGsFM= sha256:TkYp0Jxa4mRLo1lSzO3J+8t2xqPpXMwjH0AZ54AdbFQ= sha1:p34bSCrVT8soFIsjZGYvB65IHEY= sha256:eRDZd98xJGmya+s3Y2qFNW8cMFkjSOd9lrdzWolYsKo= 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 3660D1131E7; Fri, 6 Nov 2026 13:02:07 +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 jlLZFFK0IeCJ; Fri, 6 Nov 2026 13:02:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-357905-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 62DDF11316E; Fri, 6 Nov 2026 13:01:53 +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 D6B492F088; Fri, 6 Nov 2026 09:53:52 +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=1793958831; b=ZNhGz7F+p72nwRUm9ZG6zqEC7ZzyAAwxpTxvffbFnrDFIvwQJVBpLBODL3bdgvU9+kAW B8d6JjHYfBMU1N/rCXGQ7cwjnCO4XJUkxpAOYRZM4U8+myZ74Bx0j4LKaVZNJPdZBuSKd o+dHrOr7TyCG/k6nJocVYmpqbi+wrPd8oMXaaK0QuTc0dAwcxAY6nba0mia+YQlyFLlCj 0v76zc7gnjHH7WfYCJWSuYLODSWItwY3XpfqRiNKGZA60pNTCExDd34vlNPEdyBG1re4L XZ5ree1vWx6cQyvGjL7HhzklJgJ4xASLb8nWdTLHtvruZwdBYvAIu780Q7iWXSaTc9w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793958831; 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=TPtoN24RCPZqza8zVRYNe6NT82pRGbAqqQ6mEC0+6icGdrw1QAc8yhGfj39sUuKbnPdx MXvBZIOgYcjBJsxNRhBqdb/dnQWRse8kGQva18giKNa8CRDKufPeDtC6irdv62nbtFywY M7grKOjOu6hgG6VpYI4M0VHBomK8E8tEEAWUvbhwGeYCYU9op/CgpgnxzeihSw6cGMkbm LVAuCP2/slyYverktRcTCb6aT33C2Y13ztb/Hk1srcRdEvZfGMpbYJa7LnxzgbcQxtoS7 UleHCxIojoVmtQAHem91NnawDWm6AzY8BRQsoMaC/qCtdGrqYx4qL8xasEddGfcy2Rw== 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=QexeoRwv; 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 A4E87606A329; Fri, 6 Nov 2026 09:53:51 +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=QexeoRwv 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=1793958830; b=LFk43MjiAzhf7681bbSdZ+ro77r82maRpBnVRqFRHzcCPmKTVXE4zmJ5XPQOoHL77Gx1 sAOeFRSHSp24VsyqY3Lq3hkGbsCoe+mwnOpw6oXNIBY7eD3znVGZCbF0uJZvBmuJxZkkV WJJ37u51tMo8IzOJll9KTKQMXP5V3PkelxOaceY/7wOJXORDhcNX+VKr1lEaYO7ZqaRe7 G4uCDKJa6rjAIcEygf+evWamy5raBePK0tPbUlBbhuuFRC5Qb4NxImTpRerCQm5EHeJyd JD4Y2eLtlmToz5+UgLylKuLmfP7Yiid4mmjEKqgNx1yvyf8T86/lJVM9bGaQAGAv8ew== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793958830; 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=idpzX9PFm2yNiuaJV0NG2oEuSUhwV9CSbVreKxPKDIAUbLW9MYDgIALa+bwBHUtzV1Cw 6D+m1oL55CAiyKdPtvGSyxIEObWRmCnnuz11kgWhgNQ8gKZLyc0dr6ATrEWK+kEDADeEl tuZorGiDbrLgVAVtxRHtH0O1k51T19sBkCKGx5z+U8/QPRJGgD33jerOv/eQw8lFasx+n vZmUvflGu+eI0HU6sUu5Gx2alEzaHLA8AjpIVIV1aTSRVCBCYF0Oxy1vGp4f00BnubxDl Kz4/gyntAvy0bS/dvh/0uMe2mpbWUT+9D6eDkJXXiC2SQebzQQWfU/L0n7wmPEgboGA== 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=QexeoRwv; 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 8B91C606A32E; Fri, 6 Nov 2026 09:53:50 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEAD91F008A2; Fri, 6 Nov 2026 09:53:47 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793958830; bh=43PEyzcC+jmO9SuRFxvHoqt9FvZx25sEYcqX+V5QNzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QexeoRwv+e5S2YWIOrYYeLwNqIyKNqYrbBvVqqZx/SA/X0Rgrr73852bm+eDmvpLL TwEnfpC4nq/jSymPkPpuoEvuSMj2Qkujnr9TgINTe9lA1/rmnYopVIrqMrnbXuVrol AGgFgPMUb2huhiFvr14QWwvHZfPINaPSLl079bjKxoXw2MruvvAYrbET6qETi0oD4q Uobkn9Sf2zGRRfs8F9fy3/sLPebRiEDmZ9OhM8rffHimlAiDrPaMPG+BNZVOo+AX5F o81xFpIwcSrh2CEVQg1+WRumjLrDCMy/CWLHw3QIp7AZjUfocbZCI19pnZVj4IOz1I klQquK5SKCxQA== 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: <20261106095340.2113683-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