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=1796388535; b=VxJaPr6VZkEpPxOhf/XihNWZ+nt29cJBUZw2dk7O+MDnBuBSw1nmfMfG/1hzQPCQIBc7 Ud/NvWRCe4Bq/UUQvkjvG5/Ltq2KzhbtZENldUlGSDcE6WprkY86x+q30bLXwe5JlS8Bq +s6hzhkKSp9LLcQFnRdrZ4zUeS9uzvgwpdhsJTTJ22D29bdHNIk0nxX3Ilz8Jkdh7I0U7 2wWA3zhIwGpEoi1ZztPI2RS5bsyYY4lXVuMJmHv/HM1cea/AztNkdbzFU/9EqGW7BRyet Tr95z/ht3AbnZ/ExBqv2GcyRWOKdbGIguRHVyfSSOmBjswcf2N+byf87arCPqz7cHxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388535; 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=1SYC/6pv1iONYd0+qh1+b9m+7pD5xbe7nq83g1vkXUA=; b=4Ti/ExHuKFHV6HSJ+TPZA61sQlp2D+bXFh3fznpNr1hz6WYrLYlXog+rPT9xKLwpa6hp C+NhvgnwuD7oqvsw/FCMOq+juR+I8CTTzmTgYguFDp/czrZKiU2CvnY2VqnYPA9/PXlQs Vu5wScVk6t7trSaCsa9jjIdzGhUJ2vzDFhlK2KL7hwAkbyoGIGfIqyqmb0O3WVPDGmQHT eDRO0d1/B6NISTgf5t3b/1UTJtz+MSnLEXKgtrFWSgqjTqkkVHzebtTQuVMe0VrT34euT EG1ruX6kTFgD+H4zOyncG4gLXKD/6jGPpV8v5Y3HD0csdUZNsFlzKZUTcuic/rTJEAg== 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=b16yIx5C; 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 546D7606A32C; Fri, 4 Dec 2026 12:48:55 +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=b16yIx5C Received: by smtp.kernel.org (Postfix) with ESMTPSA id C80531F00931; Fri, 4 Dec 2026 12:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388535; bh=1SYC/6pv1iONYd0+qh1+b9m+7pD5xbe7nq83g1vkXUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b16yIx5Cuy9nIfn1iTFBtopKCUDXq8mPJ9iwKJ1QHlMGDygxDlL3Q1S/v9tr7GcS8 dKCaRMh8vs5cGpzf6KmGk3AT6SV1pIOS/H/KrIZINZXvPdiND6iopZ8B0zbMLMUVpa zZEw15m68YGWJCA+gr8m37vy46l9scSvNd1kA4g4= 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.1 0654/1059] net: ipv6: keep room for the mac header in dst_dev_overhead() Date: Fri, 4 Dec 2026 19:03:05 +0900 Message-ID: <20261204100700.995736835@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: 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 96dd65a941c51..9301d36d3af93 100644 --- a/include/net/dst.h +++ b/include/net/dst.h @@ -441,7 +441,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