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=1796384125; b=b6jWmVXXMwjzMnN0ef+4rucFj5x+Wk8yPuvrgidbg+EaEW5IGR0Tw28232X/fZ1iAeDO UQg08bVSoWzdEcqN2I3UcWeW59gMjtNvm9r0TzMidNH9ykciCYb/EhDv1sDnbOOEJfQXK Ih5JjCyrgohBzTeLltGCga9ynRBlhEFDXmECqGQnhVkJayLzZlMTbQ4KHoemojDQWQrXr V9ykXOhQpJ2Sp/evN+CQRR/9PiztN8bzq71VugBKfmDawUFBu1FASk+LiH159suJ7kaip Dih+S4nWmpc8Hu/b7sDLjKwZFaA8ZhwXqR4fpdlUBJNMNbcL3gvimcNyT7X8tAvA2gw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384125; 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=Fk53e/m9Tch/RowNe9DYvv4svMvwVj/bKT7nXz/282s=; b=B3ohnsALKwABsyDbACEKQ4asunmyawK8BSGLwgPK8tuDxeasqlZfhSuUTg7OG5kmCUQa kQqQGu2ogCJD+hGRO7DlcfuGZiZRKo9C62eA96BxfVztGYmoFIHdm/HxGhWi8d+EMPzG9 XBltegzW/aOWV6bcay5Lk4Y4HvqtH11hBrM5FsUCC65AKAVMQ53nK0I6UE+Xnz1qAlRh7 zJ2r2Hi8ie4DJIO3easpQ1xBQXE1bm56LHtT7Bw+4Y7bTbIwrbsoOcSiRRUg+GyV+mdsy wURtj9doF7jJxr1QiKR2gGm0Hex7JrA/LfqfAkjoV6RfF/w+LpiD4e698aRiFeiWWdg== 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=fDE+RMAh; 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 C2080606A333; Fri, 4 Dec 2026 11:35:25 +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=fDE+RMAh Received: by smtp.kernel.org (Postfix) with ESMTPSA id 602B41F000C2; Fri, 4 Dec 2026 11:35:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384125; bh=Fk53e/m9Tch/RowNe9DYvv4svMvwVj/bKT7nXz/282s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fDE+RMAhZ3Piog81ZgGA9zK4+XGkGOhW2xWBtC19GOKauYw4zwvN4pNGLBRmUp+78 TEtpsc42NUSwiqEi9P678p3O2xjryLKh81TBuFZa+qHpF3Nra3zLtSnnU7EvBQaCL9 5kERvU1LHAFCqoUFBPHXEno9qyogc0xrMt5LeKis= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , Stefano Brivio , Justin Iurman , Paolo Abeni Subject: [PATCH 6.12 456/555] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap() Date: Fri, 4 Dec 2026 19:08:19 +0900 Message-ID: <20261204100626.760546146@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet commit 02f578b736f1524ed73ef879fb1cf1ba4a875aa4 upstream. skb->transport_header is a 16-bit offset from skb->head, and U16_MAX is reserved as the "not set" value. skb_set_transport_header() silently truncates an offset that does not fit. __udp6_lib_err_encap() stores @offset, computed by icmpv6_notify() from the extension headers of the packet embedded in an ICMPv6 error. Should the value be truncated, the tunnel encap_err_lookup() and err_handler() callbacks would read the UDP header at the wrong place. Since commit 3744b0964d52 ("ipv6: Implement limits on extension header parsing") a single chain is bounded to IP6_MAX_EXT_HDRS_CNT headers (24576 bytes), so this needs a large skb->data - skb->head on top of it, for instance after several nested decapsulations, each of them possibly pulling its own extension header chain, since @offset is relative to the IPv6 header embedded in the ICMPv6 error. No reproducer was written, this is hardening. Use skb_set_transport_header_careful() and return an error if the offset can not be stored, in which case udpv6_err() ignores the ICMPv6 error. Do this before changing the network header, so that nothing has to be restored on failure. Fixes: a36e185e8c85 ("udp: Handle ICMP errors for tunnels with same destination port on both endpoints") Cc: stable@vger.kernel.org Signed-off-by: Eric Dumazet Reviewed-by: Stefano Brivio Link: https://patch.msgid.link/20261113124625.4010206-6-edumazet@kernel.org Reviewed-by: Justin Iurman Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- net/ipv6/udp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -576,12 +576,13 @@ static struct sock *__udp6_lib_err_encap network_offset = skb_network_offset(skb); transport_offset = skb_transport_offset(skb); + /* Transport header needs to point to the UDP header */ + if (unlikely(!skb_set_transport_header_careful(skb, offset))) + return ERR_PTR(-EINVAL); + /* Network header needs to point to the outer IPv6 header inside ICMP */ skb_reset_network_header(skb); - /* Transport header needs to point to the UDP header */ - skb_set_transport_header(skb, offset); - if (sk) { up = udp_sk(sk);