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=1796384039; b=nsvnvaXlRWolIghk4lbvhMtKyn5/+8jWH9mFMyN8fQDpHRUbUvKDRVrAp4zqb+ISfUlu unTNY2bhlHKV+Z7FzQ3ZBsjPK9xVzLOafX0Pr96vR2X4SReis1DeyC/tyvklt4x3LOIoC lloeaYsf0zwq+V2sZwYeaS5HksCQ/K1YYih//R7KAAP9epgtp4jnxuSHdcigY3lhjmGoG 4AV5jgmxUtctI127ImX9ZFCd3Kf9zzUg8lr8dAINSBOwXV6jBuHcnEjdevlSCBlIXajj9 tLgkd4kz9uGoSkUY1skRMe5KwbgFoFVOVzr8lKY7V0rcjXio5gIBsIgp9BIBcwNWFkA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384039; 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=1+QZaF4W/qwfuYtaIj5ymfNgb3/cyJT1nY5DTikSZQg=; b=nw8sK0FXxYYDSF47ASf6uPPnx+JZz8VKilnVthtalLNDXijIhuu7CdVLX8yslunNgd94 YBAgw7kmViiMruxWTAXUliU6sLKuneF134e+171kb8tPSiW1BEO58yHxfJPPzM2QZqLfW /n1b3TCoNorPnA0sKxaW2xgnzN+4zpKEfAFu7MtL2ZsSgwPzsHiCf5JGLMIYelLi6/ilf lCpsgMuoH5DzUJ2TCMauNsnUBVN/K28WDRe7Bcdx4yL0lJK9eLRUTBCuiqDDYjJNep9wP 6weF1P+Bejwc7WfO2bXTpT0FVfV7MYiMQPA5pZHMiT7jhkGmmHgNhkaE7zAdb3G+O1A== 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=IvSfNOZK; 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 A4BC1606A33B; Fri, 4 Dec 2026 11:33:59 +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=IvSfNOZK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B50E1F0092C; Fri, 4 Dec 2026 11:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384039; bh=1+QZaF4W/qwfuYtaIj5ymfNgb3/cyJT1nY5DTikSZQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IvSfNOZKeKR3K8V5UPGyJuQiOEIdG+XNCtFt2UiP4L5lTtvd+HhM+OgdnV5HejiDD 9PIUQKzR/qeOierJBjkTp9xc7q8k2csY4bzuTzgAtyt+QqwFn0Nfn1P8W8ZiL4Af3z sRWivtTwni0OpaTBHjuO2bZ0czf8cIFqGSyNP+YE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , Ilya Maximets , Aaron Conole , Justin Iurman , Paolo Abeni Subject: [PATCH 6.12 471/555] net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr() Date: Fri, 4 Dec 2026 19:08:34 +0900 Message-ID: <20261204100627.221069156@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 b9b77e2430032c21cc82b7da3a0bc0d8e74e6c26 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. parse_ipv6hdr() stores the payload offset found by ipv6_find_hdr(), which depends on the extension headers found in the packet. Should the value be truncated, key_extract_l3l4() would parse the L4 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. No reproducer was written, this is hardening. Use skb_set_transport_header_careful() and return -EPROTO if the offset can not be stored. As for other ipv6_find_hdr() failures, the caller then sets the transport header to the network header and does not parse L4. While at it, use payload_ofs directly, since nh_ofs + nh_len == payload_ofs. Fixes: 1a37e412a022 ("net: Use 16bits for *_headers fields of struct skbuff") Cc: stable@vger.kernel.org Signed-off-by: Eric Dumazet Reviewed-by: Ilya Maximets Reviewed-by: Aaron Conole Link: https://patch.msgid.link/20261113124625.4010206-4-edumazet@kernel.org Reviewed-by: Justin Iurman Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- net/openvswitch/flow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c @@ -443,7 +443,8 @@ static int parse_ipv6hdr(struct sk_buff return -EPROTO; nh_len = payload_ofs - nh_ofs; - skb_set_transport_header(skb, nh_ofs + nh_len); + if (unlikely(!skb_set_transport_header_careful(skb, payload_ofs))) + return -EPROTO; key->ip.proto = nexthdr; return nh_len; }