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=1796381205; b=EppMnoggmGtPnYDuFr2uqXUM8HAcIK6YhRCLJ139i3UimRD6F/kPeSvXaiLSdPccJTl6 UFWTubnvO8CKmuOF3YolQaXWLiaw9k5mqKUVjZUtghxwjA8S3pF9OwCqVeqPc4o/WIKaR HnXBIKjGb1e2v3pjnBZSjbh7npCHxNf1KoIhPHxIeAoX9LvKi8cE6mTLz/NGjbJNo4d+Q 4JpUQ9FU0HaEKd3e2hPA7Ru9INPeqFPCCzQdVsYIp2L3x4CcBsaZ3yra7Q/EIkYQlshRn 0LUfm/FRXNXp5l3Oit01LuH1XFWY2ufCl+eWpF4cVpOmjGpNkYeXgG6EaxfZBjPdYQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381205; 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=eLk8t0Wh30wuqLm2inf1Smqv4y7Sw6C7SOq9AkZcmfA=; b=d9YomgbX3bpqOVOJtBE8iwXrwqe3M5lHcbl56vatSIEtRSgPYHhum08UKwK4BT8GtLeW TN+O6Nrgn2Xl00TGK+aqvLxty1KcI4O+oLgJrjpDMWc93D1cg5Yf09CFGiSgDgqJ4shiZ PeeWxFQv5iEjw5CTimUgYYHANCnBtmxIbIsECOTRLcNMLBi1Sd/d2nS4Rq87HFzu6DkeG zw6+v7AypJosLMzwIXS6JoY22AZ/wI6548br0WMPMABMxBDy1eCWdcGVWQLrxTwRG9t8o qBMCy/qKgTa6iY/YS0hBDiTMxfoey1k6KoSb2lI94zB3JCBovGQk84V/pzzf8Re5RiA== 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=w4DJ5CWT; 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 6583A606A322; Fri, 4 Dec 2026 10:46:45 +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=w4DJ5CWT Received: by smtp.kernel.org (Postfix) with ESMTPSA id D45E31F000CE; Fri, 4 Dec 2026 10:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381205; bh=eLk8t0Wh30wuqLm2inf1Smqv4y7Sw6C7SOq9AkZcmfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=w4DJ5CWT/ht0cNF/nyl9GYQX+q/MwcA+rzVxfkRYccuMUIvl+WjBcGMcIJJOoOrXv 15QzIjKHzypPL0LnBGG/1VyIx2b8mJ0vlfNXrhtFW9KFgpFh7JHLuem2Tse00Ljgxl VG92lPZosQLPW7MK0cCllXaJwc6mtUKzmhXgyx/4= 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 7.3 603/742] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap() Date: Fri, 4 Dec 2026 19:07:47 +0900 Message-ID: <20261204100651.139953572@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 @@ -651,12 +651,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);