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=1796388048; b=EH4A0Pmi0T2GHaRg6N+X0+6P6+a/rCyK5sCOLHKUMHt0goDWLFwAW8TvlPML9m3Z4dXU 9hnO30Jr/RvyscVcqpNhLfWkFyk4Y0gMJsPR7RdWHReTPahagXjyWzfxb4xxKr9oLPS8h 2X00fe4Ux8bNhbYyKYc7tiKUDrGVgXuwnFcl31LZwjXQbFokV/kPvT4lxuXmg9D74y3ZN I6ppt+PjqRCznrrMEq59x1nU1fGmUaZ/gKRHJTCOMvNCZS+2j7ppMVsL8KIxu+iFeVfbv OxBV0uabve1CiMEE+zqX2vVzcOe8Kqd9oCTKFTEOlQCU4HAn8d/YX+IuLe0I06DzXUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388048; 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=d9jVT2JU4NQFmA9zPAW6hwDbW20XPfTp8JYn2fCqTM8=; b=iYONt/pQp+olXbklOO/1qzpeMt3fgWD2pEqfcUYRzAR1b1l2qicY/2ZsU9UuKdbOj9bA J77tOGHUXsp9Kf1B2FqJAFqxWlSVyjLrRfdxTB+xNjF/nc8zH9m93tJc72q3mBz1vUHwX edYSeL0FskGcWnu/P/2I62ju7l33ivWxChWVvvnjYDHM6CSsXAC/J8PvgQUJ9MKy9LK+p F4c31atCeEuEtQ/6C6tDBg2O+adqEqDbkXreJc54voqkdrVoyTRqg3pvZycB2jInqyUVj nV2bjxcKWVDlaOtj+WCYlZYwL3VmxGJTCYtCXG48lh22LlZ+lSZiKNa+qEqbRhj9SxQ== 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=iV1o4tnu; 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 902A5606A338; Fri, 4 Dec 2026 12:40:48 +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=iV1o4tnu Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB3ED1F00933; Fri, 4 Dec 2026 12:40:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388048; bh=d9jVT2JU4NQFmA9zPAW6hwDbW20XPfTp8JYn2fCqTM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iV1o4tnuBNsOiF/y/jICE0DuBJh75W8M7Pb1dj86lrziiEgDeBb7gStdAg+Ecm24d xEi0RZJGFwE+0AmxTi2Hobdr38jchGe5NuzE2KYDXZQbbxvJBOXH62zAgRgf8+USeQ Pl8Q8dI75OPgSMJflZXHQ8gL+SfmAie2bG6pf9Qg= 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.1 0465/1059] tun: clear stale skb->protocol of NAPI frags skbs Date: Fri, 4 Dec 2026 18:59:56 +0900 Message-ID: <20261204100656.311365179@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-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 df786382da6b1..b03628642c2c2 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1485,6 +1485,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