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=1796385966; b=hVhbpM2TUXTI8SDQg39iZyV3brDJiccd6NK8de80KU3HKmeMqNkEUckC3Mrw7a7p67g7 0usUuzeWa4cosumhgju54qYhZbiYwtzxU0l4a4nRyjinVPaHllFqBFIZRayMuRXWxEnsT bFnK1VT2eZkDbG5cih/BNm2G2Ph7irQdBmQYp60l1ZzPeR+8wTLsc1Bj0Dz/Ft3jXSjLp CtzaN2dBAVdSUjfqBvqK+VrQ9DPP/06VF4d8PiL+bVCu4srIGcV47/jsu+qdCyzXt5z1v 42bX9jSUIzDelQy+juICpJorSebn6gRB1omTr6bMB+BS/uMRWGRWU5E9Yru6olNidjg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385966; 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=dEjqN0ZWghgHFGaC/GNImKBHz0SKICvaCG8YwtR7LXA=; b=PTCGyZolvazhC61olAcealziL4i3k0skLVasceiczoud2qyNIFzI2xrZvqgA0g4+lBwJ 9Xr2RPVqJvftuwR8bJ1LbXHB8Tfx4C4pvYiGz1xzRyIMjurx7WqE92nHLqhkwvhlkw5Sm qUdLGKWb9MLtV9UXqc6ysDEk2sUTm0rQLdi0ICzfrENwbMkbrf4Sjgb/CdowwxwmLassL HYBlBBpPoVn5Vl68sekD0NwNFCKzM9CIg2tX/EBoJZaZK98HsnB3Kq2UoP6JHoD35V3HO 0f+iMfgVUvuEbMS7MMXefcvySSrpu5CmIrL7csQtYWPTteAws/TT3DoBVajTaBNXReQ== 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=IoGtGEmI; 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 1EB56606A322; Fri, 4 Dec 2026 12:06:06 +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=IoGtGEmI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 949211F000C2; Fri, 4 Dec 2026 12:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385966; bh=dEjqN0ZWghgHFGaC/GNImKBHz0SKICvaCG8YwtR7LXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IoGtGEmIW4IeOe4gAk38PBmzKiGxQqLgRs3S58kQwYR41o7PhMY6/5dSGJeqKmFoe Xg/cTlKSo0pNC917RFDC3KlIcewmHQ0slVFoSlprHTMq7zYVmn6rfEZ167rnZ6HVxH fe1rKNquCTZTIyl75XS/Y/Dj/oZ5/QOa9tS60D18= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andrea Mayer , Yuya Kusakabe , Justin Iurman , Gabriel Goller , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0717/1167] net: ipv6: keep room for the mac header in dst_dev_overhead() Date: Fri, 4 Dec 2026 19:02:24 +0900 Message-ID: <20261204100720.748808196@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: Yuya Kusakabe [ Upstream commit 87cd6b717e4069dca34e0866e57eaeb44d3b173e ] The seg6, ioam6 and rpl lwtunnels size their skb_cow_head() request as the length they are about to push plus dst_dev_overhead(), then push the new headers and rebuild the mac header below them with skb_mac_header_rebuild(). That rebuild needs skb->mac_len of headroom, but dst_dev_overhead() leaves LL_RESERVED_SPACE() of the egress device, 16 bytes for plain Ethernet. Where the mac header is longer than that, as it is on ingress through a VLAN device with reorder_hdr off, the rebuild runs out of room: skb_set_mac_header(skb, -skb->mac_len) computes a negative offset, stores it unchecked in the u16 skb->mac_header, and the memmove that follows writes skb->mac_len bytes about 64 KB past skb->head. Forwarding plain ping6 traffic through such a device reproduces it on all five seg6 encapsulation modes and on the rpl and ioam6 inline paths; skb->mac_header comes back as 65534 on a 704-byte head. Return the larger of the two. The helper already returns skb->mac_len when it has no dst, so this only makes the other branch agree, and it covers every caller rather than each call site in turn. Fixes: 40475b63761a ("net: ipv6: seg6_iptunnel: mitigate 2-realloc issue") Fixes: dce525185bc9 ("net: ipv6: ioam6_iptunnel: mitigate 2-realloc issue") Fixes: 985ec6f5e623 ("net: ipv6: rpl_iptunnel: mitigate 2-realloc issue") Suggested-by: Andrea Mayer Signed-off-by: Yuya Kusakabe Reviewed-by: Justin Iurman Reviewed-by: Gabriel Goller Reviewed-by: Eric Dumazet Reviewed-by: Andrea Mayer Link: https://patch.msgid.link/20260922-seg6-maclen-headroom-v3-1-7b2f982ef79d@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- include/net/dst.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/net/dst.h b/include/net/dst.h index 4b54b2f6730ef..769d18945de65 100644 --- a/include/net/dst.h +++ b/include/net/dst.h @@ -455,7 +455,8 @@ static inline unsigned int dst_dev_overhead(struct dst_entry *dst, struct sk_buff *skb) { if (likely(dst)) - return LL_RESERVED_SPACE(dst->dev); + return max_t(unsigned int, skb->mac_len, + LL_RESERVED_SPACE(dst->dev)); return skb->mac_len; } -- 2.53.0