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=1796385378; b=VVaQ+PuCDJzsvsEKlKHy/0lr54rI1R8wIbNUreBPLD4SuAQFNZEH4POWnKATeiON8KJV NN1MvymWrD7C0oYpkMuV6tcbBwy4398+AmYR3mNp4Fs5mVSKA2N/Wti+jkyHRd6KOaLMG p1OWO85uGClKEa0CTSeTCrIc4z1FN4LaL9SO7wmYbVRsT9J9XiNdi/0BodDkzkDrzi/Xx E9MaW0g0GyqY9ndUJEvzTlkuAZQ6cvmbdubGm0CqmgtCAmqmaMCZkdUPf+LXN0gmWai7z 6d0QlyFdh66IBhJj76oyWU8gq7Giqs5yuJ98XKKsiz0OWK1NVMP1URdPFdoMZ7pQv4w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385378; 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=HB8TBHlxhBJaMcL6Elxt5KxJte2gBdDwH9kylZU5QJc=; b=l9zJx5T1bRu4ftyrlXng9v66VjmqwrRG26aEEYKfC1LgYK9p2YbvSFJZ3E4HUDFpT/tQ 7TqYi0+g3JVHLLjvZqaniMC8FP9CDvMJQJof96f6afTo2KOKI47DxbC/6oMXekO599Hx+ 2aGfAZj2CTwqSINjRIBISp/YZ8q8LTTKT9NkKQHs/GMboI4Q4Il78RTUBjbU2aSbysc69 BmdrdW7Vwbi4DOJdZzJJpezVrCGv94Pi2tMVTfg/XEoK4Z5bES2ZhhRhxNhmqbgdZPZ2f 51XZ/jHGVFhLLUUKsH4crcYd0MPs6NydZrTKXy1VeVLyoWdETKuvOcqENE8MhdV/6+A== 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=ffOJxWZK; 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 D4183606A322; Fri, 4 Dec 2026 11:56:18 +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=ffOJxWZK Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF7091F000C2; Fri, 4 Dec 2026 11:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385378; bh=HB8TBHlxhBJaMcL6Elxt5KxJte2gBdDwH9kylZU5QJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ffOJxWZKz0KlZPekvpHmUQeAy1se6a8Yy1HbxKUcIUxrlsLYgLShfHDFiul9RMY/I R6nO001qyb6rRjse/PKRh2Kaxn6GciAleM/pX+gWpItpDOR1DcHmGQoh0rS0ClCplv 1mpqa7VZL4cCbLJwGvo9RPGtF6f1et6bQlFMUUbQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joas Antonio dos Santos , Simon Horman , Aaron Conole , Eelco Chaudron , Paolo Abeni Subject: [PATCH 6.6 0531/1167] openvswitch: advance by the real header length in get_ipv6_ext_hdrs() Date: Fri, 4 Dec 2026 18:59:18 +0900 Message-ID: <20261204100715.885720051@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joas Antonio dos Santos commit dbce972650ed6348e3d3856e49308aa5603e02a7 upstream. get_ipv6_ext_hdrs() walks the IPv6 extension header chain to fill key->ipv6.exthdrs, but advances to the next header with ipv6_optlen() whatever the current header is. That is only right for Hop-by-Hop, Destination Options and Routing headers: - an Authentication Header is ((hdrlen + 2) << 2) bytes long (ipv6_authlen()), so with hdrlen = 4 the walk skips 40 bytes instead of 24 and reads the next "header" from the ICV and payload; - a Fragment header is always 8 bytes, and the byte read as hdrlen is its Reserved field, which the sender controls and receivers ignore, so a non-zero value makes the walk skip up to 2048 bytes and miss the headers that follow; - in a non-first fragment nothing after the Fragment header is a header at all, it is the middle of the fragmentable part, yet the walk keeps parsing it as an extension header chain. In all cases the OFPIEH12_* bits stored in key->ipv6.exthdrs depend on bytes chosen by the sender rather than on the headers that are actually present: payload bytes that look like another AH or a Hop-by-Hop header add OFPIEH12_UNREP/OFPIEH12_UNSEQ, and real headers after a Fragment header can go unreported. Flows that match on OVS_KEY_ATTR_IPV6_EXTHDRS then classify such packets wrongly. There is no memory safety issue, skb_header_pointer() bounds every read. Advance by sizeof(struct frag_hdr) for Fragment headers and by ipv6_authlen() for AH, and stop at the Fragment header if its offset is non-zero, as ipv6_find_hdr() does. Fixes: 28a3f0601727 ("net: openvswitch: IPv6: Add IPv6 extension header support") Link: https://lore.kernel.org/all/178905555085.219967.6617611783437228045@kernel.org/ Cc: stable@vger.kernel.org Signed-off-by: Joas Antonio dos Santos Reviewed-by: Simon Horman Reviewed-by: Aaron Conole Reviewed-by: Eelco Chaudron Link: https://patch.msgid.link/20261102-ovs-exthdrs-v2-1-21ceef6a243d@gmail.com Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- net/openvswitch/flow.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c @@ -374,11 +374,28 @@ static void get_ipv6_ext_hdrs(struct sk_ return; } + if (next_type == IPPROTO_FRAGMENT) { + struct frag_hdr _fh, *fh; + + fh = skb_header_pointer(skb, start, sizeof(_fh), &_fh); + if (!fh) + break; + /* Only the first fragment has the headers that follow. */ + if (fh->frag_off & htons(IP6_OFFSET)) + break; + start += sizeof(_fh); + next_type = fh->nexthdr; + continue; + } + hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr); if (!hp) break; + if (next_type == IPPROTO_AH) + start += ipv6_authlen(hp); + else + start += ipv6_optlen(hp); next_type = hp->nexthdr; - start += ipv6_optlen(hp); } }