From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385258; b=RddVyUmWMZ5jA3NRgfgMxUJx1TKHudTHtq/4pj+XaYl/VnxJmNsPpz6AAgi4ItnCLssp jJj+erC6TyIHWYVyUu9362yHJX6sQkn+SvyjWVoW+ddd5EXIqsVsKKvOepTakQ2EUBsz9 NIlglCrETgKsjZwxe9TxKjE+YX6rRFMxPWOTMy5gh6moi+eWhlutNFkuFm1OqJK48mwLR TyZR2w9eLmH5YHS4HO6Ut5CAwFSZjULLZ58yCGR6Shni7qXJH8CIcQuziroSS27NSZ7HE wFe1EIicm9aii6VK0IfMEI0A4PgYB0IFCc3HUvbfxUOGQFT9P83T4MJ2pBAf3h9WhSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385258; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=WcaaTgv206wZz1sGM+jh/sup9eJuH8FsCYxefJ+Qtio=; b=n9PXDLJfGdHs5f95kC2mbbvWm2R2NVjFN2nSacUCKB/wJta+MxXfWmMAUdXMLNhounzK q2oM+K14MvBhSO+wVbmY4Ll9PhZATiOI9T3aNP4nTEvXyuInTHTBv0s2CsJeEDnjrUxmD YBihQfROwyaDn1uCq9B3h7c2LvhMBZyguM9Wa6SalP2HkgTnQ7yDgj4zgtlHwUuRnjFH5 d+Vc+ZeQSVV8LygCLu9K5f9q1cfRLFMqSoZfpQx9lqs98Qvj6jvtZGy0VyFki/6bSQUfv ZhvjiPmCu5h3+BbEJQAMl/MBX6c40DzTtrx1vOjdPjsxxRyDJEM8uh09RTEY/pZo9fw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=eoFE4FeG; arc=none smtp.remote-ip=100.103.45.18 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 54EB6606A680; Fri, 4 Dec 2026 11:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=eoFE4FeG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A19F1F00931; Fri, 4 Dec 2026 11:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385257; bh=WcaaTgv206wZz1sGM+jh/sup9eJuH8FsCYxefJ+Qtio=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eoFE4FeGavnh5siuPNAnKkEgztP3Huc/qehEM3NoOgE8PqeIvaxPn1XLaN41pFz+w Z75a9yrbm6CKqmfiIR5x40IHuuc84xM1rmuODRYWG0bSYU0S0H8fkRqEgXR/vlLFtH SyxUdzPf5O7bslHQ81pfEF1/12ixLqMQD8NvTfJo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Willem de Bruijn , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0482/1167] tun: clear stale skb->protocol of NAPI frags skbs Date: Fri, 4 Dec 2026 18:58:29 +0900 Message-ID: <20261204100714.615289860@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 3287cd714a853d9443c4a743eca010aedcfbbcdd ] 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 Closes: https://lore.kernel.org/netdev/179386753589.488856.11455181721004759454@kernel.org/ Suggested-by: Willem de Bruijn Reviewed-by: Willem de Bruijn Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20261110213628.3476051-3-edumazet@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/tun.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index e81a97944d7c9..ea808985fbc4b 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1490,6 +1490,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