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=1796384649; b=R+vEg2Tx9cziKwSAPXuBEq37Ow2xr+dSF6+Muu9DMIZ78ABUGN7zqgIg6XaKmDFn11S9 lhX3P0zUjOT5F8jaVuIaU60szC1JQ97uBQDwl2vZxk7xu6ShxGeZgsXVJv4Fh2zopWmeg /t8za50Goq7j6VFTN0bQ9gpTGUgGK9m4FogqLrhmjnKgeOpXReL2Npm5bFOgAq7kZ2kQ3 Xjx3qP98CtzSgDBuOMkRHPpxIxMIpDjo5ixnPTuVbAyaYxXrIGYQRX26oGpZCTCa+9fqY t82qFcXSWHKtE1fMZri2MXgtkpmo1kzSk22zr7UZXJSNjPb9daaiUsehZbmxHL6flLQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384649; 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=gtuKWptYqK9aP6D7IwLQGmH9gKgQ21NTHs8bxXDzfUE=; b=UUWVfCQ3FnPal9jjfY85WrSqDwZuBfn+vx+hztUlkaFWIzRvxj5TynuSIRu3MoICfbZp 1+fL5BO/fwVIaG4HPW8AkXpThH4A1wGPGGjZ54+R9YWm3mdxKeCfYuZXZkBsA4LBxIUbf jYSbTv7v2/+OoBvo7eorpACCQfX0O5I85/7IYqWuJvhgZwUAYFFemVYt6jJHXUEi4MIvx sIZQ+cMtLzBBQH9lg2nhcdNGFcb/BN8E09pG+MZhIzd+fMvUJhg8EOQT5EnfGXi7SEMt+ W7yXTTxtk/1WK0vEAM70to07k/0K7AmzLpmMn6X3XHynE+O55BJpe5OqyzRCjNNDbog== 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=jBoyW0IA; 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 A2319606A333; Fri, 4 Dec 2026 11:44:09 +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=jBoyW0IA Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF5621F00934; Fri, 4 Dec 2026 11:44:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384649; bh=gtuKWptYqK9aP6D7IwLQGmH9gKgQ21NTHs8bxXDzfUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jBoyW0IAmjX51XiMJcA7hsJpIL4afUFRX7Fuq+9s8bsdcPXeYOZQD1IwdpInDEFMt qKz/MGVgRO4XrWyefNDtUQEDFwGDw+SRT2LTgtQy2E+Jr+EvodUAHMP9g2ZOKvg/ft A824VYHgXlRLK1oOG/TrrHd9xZ4v7/lSuR9rIw58= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kyle Zeng , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0234/1167] ipvlan: make outbound skb headers writable Date: Fri, 4 Dec 2026 18:54:21 +0900 Message-ID: <20261204100708.163632331@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: Kyle Zeng [ Upstream commit a45dbf182137275f44ad7c8bc8acd23f7af6b2cf ] In L3 and L3S modes, ipvlan_process_v4_outbound() and ipvlan_process_v6_outbound() hand the skb to ip_local_out() and ip6_local_out(). The IP output path assumes it owns the network header: __ip_local_out() rewrites tot_len and the header checksum, and transport-mode XFRM can memmove the network header into the headroom when xfrm_skb_check_space() finds enough room, without copying. The skb reaching ipvlan can have its header shared with another skb, for example after an AF_PACKET tap on the ipvlan device or a tc mirred mirror action. pskb_network_may_pull() only makes the header linear; it does not unshare an already linear head. The writes above then modify the other skb. If that skb is on the receive path and its IPv4 header was already validated, IPv4 option processing can use the modified header, write past the linear data, and corrupt skb_shared_info. Use skb_cow_head() before taking header pointers and entering the local IP output path, like ip_forward() does with skb_cow() before it touches the header. Only checking skb_header_cloned() is enough here: skbs that TCP transmits are clones of the write-queue skb, whose header area has been released with __skb_header_release(). Their headers are private, so they are not copied, which avoids a reallocation for every TCP segment sent through an ipvlan slave. If the allocation fails, the existing error accounting and drop paths are used. L2 mode is unaffected. [edumazet: use skb_cow_head() instead of skb_unclone() to avoid copying every TCP segment, reword changelog] Fixes: 2ad7bf363841 ("ipvlan: Initial check-in of the IPVLAN driver.") Signed-off-by: Kyle Zeng Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20261104113530.986664-1-edumazet@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ipvlan/ipvlan_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c index 268ea41a17d52..fea77f2855e8c 100644 --- a/drivers/net/ipvlan/ipvlan_core.c +++ b/drivers/net/ipvlan/ipvlan_core.c @@ -425,7 +425,8 @@ static noinline_for_stack int ipvlan_process_v4_outbound(struct sk_buff *skb) .flowi4_mark = skb->mark, }; - if (!pskb_network_may_pull(skb, sizeof(struct iphdr))) + if (!pskb_network_may_pull(skb, sizeof(struct iphdr)) || + skb_cow_head(skb, 0)) goto err; ip4h = ip_hdr(skb); @@ -491,7 +492,8 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb) struct net_device *dev = skb->dev; int err, ret = NET_XMIT_DROP; - if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr))) { + if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr)) || + skb_cow_head(skb, 0)) { DEV_STATS_INC(dev, tx_errors); kfree_skb(skb); return ret; -- 2.53.0