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=1796382667; b=DzH7ak6W/D9nNniyso3CPNirSUkN3E6t0xG8gEZ660FFFkw+KfTHECAUNtN6u/So2bEH uNoE1n0mU75a2bgtwdrdfCxRPZYtPi1XI/fJmyZmgNIRiEb9EHo/qc5AK1NPvVKS4ag4f Joxs9m1KOnQzUnXGoXhb44G+OXeAgE4KgQdKk3QDlJDzbqP4VTt8qm6w0dYri5gYycUu+ fmx0f3wYlb61huKrRuKhFTbFMvuAitZpFLT9gnq4A1vkSQ1MbwPHbzw7dqo679aBRXq0r zpoPakCYdRiwip0cvfyVaSwY4a8lBhi9Af9BPByAn4N5msuBkWY7/v5ULbZ1P7Z4AZg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382667; 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=G24g47886noGaopN/CSIysyxxC+t/MOEpXXQ/9TcRCU=; b=fZIluLdCSqpSaGDxpkYsAtNf1zMnqG5BqsFRNcx+v5CyLYkfoGq7FdHwWabhIxOF1TDi n+C+SJZ9i1yvNm1IPP2TQpLZuNMSaoaWH5oJdzLhMHCE77eU+sQreZBOlIoMB6lhdIOM3 jG62FnuXck8TNTAG1EtO1kfuAlEM5320Yd/gzA2RIgTP5tBBc4ytEaj1AVELTHVbrp9KE jRKJmfhjDSgVdRRT9ZQRJFdHG6DxBVVcUDQoGjzkhnl1bNSsQMeQFXPrSzqtk7/xB2bB/ Uzjc+aeP8qI2XMykkz4TFDHWVbsc1kBM+yV5jWZxI2z11XIwcH2CI6KIWuLASfewgww== 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=Hwc0hX1F; 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 EA419606A334; Fri, 4 Dec 2026 11:11: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=Hwc0hX1F Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34D441F00897; Fri, 4 Dec 2026 11:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382666; bh=G24g47886noGaopN/CSIysyxxC+t/MOEpXXQ/9TcRCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Hwc0hX1FSjff9gqjA+N3HsJcY0p7Vu79bHvAfehzRqXhGrhQOlmkBT2S8TQcy2AF+ NaUv1LfbHouzbHDmlCWrG0l85jQ0ya+7I2priZYvuPIuueuRKEA4zQFSPtuv1Qc0WG YVTw/JDM9FCGZyWe4zBUzTou17hAfn3JxSV+gIg8= 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.18 553/703] net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr() Date: Fri, 4 Dec 2026 19:07:32 +0900 Message-ID: <20261204100642.490246754@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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 @@ -439,7 +439,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; }