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=1796388163; b=W4FwN6PAjuFbQL+jnKwKTfWPbSLPcZi2vHevdlfQv6NagqAjJ0VfefBWoSrXY8rftavh TDyzNk5LPTdWkak4Uks5pSlRI1ohL9LLlY6ATNB/TF3D4WYWg0AoqmdTrh3jUHUmd3u0u gyuiaxAVyGqPmj6gqCASzNRVJl82tRKNaWZMqaNBOSvP8MEQz4xYevLwfW0eZpbWIuzZQ 1gkt2GEm8t3r2pS7rUtuMSK7z3uMViLqFgPEjYitWH0mWnU518HKgmHPUX5UAV4inp1zy Bru5t9IL4EBFWz8HQdFhBeeDYJeOfx1JuDYjasRUtD8QSHxnuzyOfUOwaz2dHJF6BKA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388163; 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=bGPG7cga3mFNuDyOPNYBAdnQkK9bxQbylf0tbZ0eDb0=; b=xMDB2y3yCTiVzKp3MCcOEWWfi403UGJRDAw4ZQ+7FqDyOBG+kOgdEhYLqzjSenbzxbwu vy+yF3SoNeWVUheZhX/MdRhJ2T7I1QATqBI51SdGm8KDASK6A13CNqvMlbyQu9VYg9ObZ rGbHNnbmsVROveE9PMg2G9X6aL14klvBxq48I3tXryucox8WEcRnLWUDwzg2/CP407i0W xSBXK5xLm7vvTEdyqNKDkb6oAeBE5KNE11NTXO9t2bdh5fFAtEL3ViuWsZVjUvra0IiX5 FYE5gCNtc/y3osd7CmzJB4/Fwnuog5DAVZW3H+xuwpJbcgBH421fuNAFQqRE6Pk3gXg== 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=SQkthMDc; 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 317DA606A322; Fri, 4 Dec 2026 12:42:43 +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=SQkthMDc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A8781F000CE; Fri, 4 Dec 2026 12:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388163; bh=bGPG7cga3mFNuDyOPNYBAdnQkK9bxQbylf0tbZ0eDb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SQkthMDcgPvnIMGasLrUi6nez1c7bxikV2XLW1s6oWROFCOxU7Q3oNTURFGnjCIjQ 7oxuF7jiUlDQtwd3nk19IXFZFb7lW2eDdvccm3zGoDJ+MOx1HceOey5WV7FdSV0DJs rXE8xdPoDVXfKFARoM/1fUHbPlasRBUBbn2wIDeY= 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.1 0509/1059] openvswitch: advance by the real header length in get_ipv6_ext_hdrs() Date: Fri, 4 Dec 2026 19:00:40 +0900 Message-ID: <20261204100657.434958039@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-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 @@ -371,11 +371,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); } }