Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.96.220.36 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796129047; b=O9oHdTCu46+SGAUvmkDeQxpVp89k8/5vC814RUJ+3rgYvvYazAcWRFZxT6Ii5sjpSNnn PHlu+sVvHIUXZnV61sm5YuDmISlroarPM0X4yYNqE0Jl68IL0Sm1qsYd3IJmoYeED/1EF dUS9gt/ueEOEP/pCBeIQmFMQQo9Z6QQ0+rW0P+rnQbhsY1U8+Oiug/4efNoHBVk+09aYg wab7xr/CvvP8cLK8s9dL2xoCCIo0pJ15y1uLgP2yHtZnVWfuemcxtNuWtIgK01GdxNjmP 3fXRKBn5Ub27XOE25McTPiVdhz81wW8YNDLx6ERy5aelPdGzA+dbh4NUy7xGqMH0YRg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129047; h=DMARC-Filter:Received:X-Virus-Scanned:Received:Received:DKIM-Filter: DKIM-Signature:Received:Received:From:To:CC:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding:X-ClientProxiedBy; bh=2J7lAXW3i+ZeednwbKHmmoxDDuYfvFAkaqyejEbmJyU=; b=d4hfKkwOGxRCQvXCmpac+Q6hhj2oE+JhhHuSAT20kPngnWwGKgAW5uPN7s9vCS6fd9kP CDYTI886WpjjGBXWTTfuHtiY6hy+omT1lNxvoe3j6DzamR+5q1SKWVzLr7PlPMERiNJYI xwJQUGd2itfvQU0f0VHttq5V2tV75JvPRF9F04PscP/MsGee81xR3zt0xXvLCv83wDqSf uVced8JeMRIoxCQGiDShe+8csCyJbLbG5CsUdu8jT2Xy2qr1Yc+4gCaJFniMVZ3yBscKR Co68BF8WnymEHlyIv+eXJrdpJkqfJ1n66stF1Eqe8mM0YEO5cGqm4tPCWJA6jMepe7Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=cUKjUNk4; arc=none smtp.remote-ip=62.96.220.36 Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1AB6606A681 for ; Tue, 1 Dec 2026 12:44:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E1AB6606A681 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=cUKjUNk4 Received: from localhost (localhost [127.0.0.1]) by mx1.secunet.com (Postfix) with ESMTP id B349E207C1; Tue, 1 Dec 2026 13:44:05 +0100 (CET) X-Virus-Scanned: by secunet Received: from mx1.secunet.com ([127.0.0.1]) by localhost (mx1.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ncY_bOqxAZxM; Tue, 1 Dec 2026 13:44:05 +0100 (CET) Received: from EXCH-01.secunet.de (rl1.secunet.de [10.32.0.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.secunet.com (Postfix) with ESMTPS id 14E99204D9; Tue, 1 Dec 2026 13:44:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 14E99204D9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1796129045; bh=2J7lAXW3i+ZeednwbKHmmoxDDuYfvFAkaqyejEbmJyU=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=cUKjUNk4BlGTRzrgvaYO3Dj+nmKaeutPhShCiZxNw24uifI8rC7viLmmw68BoIfLJ SO6EKhH/0mZTNiAxXpo5n9stGv9bSaFjpNDz2KgmfgnoeHEfbR+IT0u3Ym4sXtgn6+ +JIexI7q0YoEABAaFZBm8UAwNu2ZVOdJPcEuz80UzJndXYECQDwpKsLHA3fyDenjmu J5OiIQl+GdYWTRGL+bl0OS3jGWpP14SqclY6QcgeG4CK/eHgdw5Us8Sak3o0N36ZtP +IIaI47CXayw0nhoyJE5sa3vZwmYW12xJ0//TFJO0Wf6WMnuyw1rpKD78jMedBAxiX FlTDne6Jn/3TA== Received: from gauss4 (10.182.7.102) by EXCH-01.secunet.de (10.32.0.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Tue, 1 Dec 2026 13:44:04 +0100 Received: (nullmailer pid 1165790 invoked by uid 1000); Tue, 01 Dec 2026 12:43:55 -0000 From: Steffen Klassert To: David Miller , Jakub Kicinski CC: Herbert Xu , Steffen Klassert , Subject: [PATCH 10/22] xfrm: fix IPv6 first-fragment protocol decode Date: Tue, 1 Dec 2026 13:41:36 +0100 Message-ID: <20261201124252.1163254-11-steffen.klassert@secunet.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261201124252.1163254-1-steffen.klassert@secunet.com> References: <20261201124252.1163254-1-steffen.klassert@secunet.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: EXCH-03.secunet.de (10.32.0.183) To EXCH-01.secunet.de (10.32.0.171) From: Jérémy Jean Commit 7a0207094f1b ("xfrm: policy: replace session decode with flow dissector") replaced XFRM session decoding with the flow dissector. While the old IPv6 decoder kept walking past an IPv6 Fragment extension header, the flow dissector stops unless the caller sets FLOW_DISSECTOR_F_PARSE_1ST_FRAG. For an atomic fragment followed by extension headers, inbound policy lookup can therefore see the header after Fragment instead of the actual upper-layer protocol and miss protocol selectors. Make the dissector continue through first IPv6 fragments. Keep the port, ICMPv6 and GRE selector fields zero for all fragments, as the old decoder did. This also keeps the result the same when a BPF flow dissector fills ports for a first fragment. Fixes: 7a0207094f1b ("xfrm: policy: replace session decode with flow dissector") Cc: stable@vger.kernel.org Signed-off-by: Jérémy Jean Signed-off-by: Steffen Klassert --- net/xfrm/xfrm_policy.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 6edf60242a80..6baff3f797f8 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -3484,23 +3484,29 @@ decode_session6(const struct xfrm_flow_keys *flkeys, struct flowi *fl, bool reve if (reverse) { fl6->saddr = flkeys->addrs.ipv6.dst; fl6->daddr = flkeys->addrs.ipv6.src; - fl6->fl6_sport = flkeys->ports.dst; - fl6->fl6_dport = flkeys->ports.src; } else { fl6->saddr = flkeys->addrs.ipv6.src; fl6->daddr = flkeys->addrs.ipv6.dst; - fl6->fl6_sport = flkeys->ports.src; - fl6->fl6_dport = flkeys->ports.dst; } - switch (flkeys->basic.ip_proto) { - case IPPROTO_GRE: - fl6->fl6_gre_key = flkeys->gre.keyid; - break; - case IPPROTO_ICMPV6: - fl6->fl6_icmp_type = flkeys->icmp.type; - fl6->fl6_icmp_code = flkeys->icmp.code; - break; + if (!(flkeys->control.flags & FLOW_DIS_IS_FRAGMENT)) { + if (reverse) { + fl6->fl6_sport = flkeys->ports.dst; + fl6->fl6_dport = flkeys->ports.src; + } else { + fl6->fl6_sport = flkeys->ports.src; + fl6->fl6_dport = flkeys->ports.dst; + } + + switch (flkeys->basic.ip_proto) { + case IPPROTO_GRE: + fl6->fl6_gre_key = flkeys->gre.keyid; + break; + case IPPROTO_ICMPV6: + fl6->fl6_icmp_type = flkeys->icmp.type; + fl6->fl6_icmp_code = flkeys->icmp.code; + break; + } } fl6->flowi6_proto = flkeys->basic.ip_proto; @@ -3511,10 +3517,13 @@ int __xfrm_decode_session(struct net *net, struct sk_buff *skb, struct flowi *fl unsigned int family, int reverse) { struct xfrm_flow_keys flkeys; + unsigned int flags = FLOW_DISSECTOR_F_STOP_AT_ENCAP; memset(&flkeys, 0, sizeof(flkeys)); + if (family == AF_INET6) + flags |= FLOW_DISSECTOR_F_PARSE_1ST_FRAG; __skb_flow_dissect(net, skb, &xfrm_session_dissector, &flkeys, - NULL, 0, 0, 0, FLOW_DISSECTOR_F_STOP_AT_ENCAP); + NULL, 0, 0, 0, flags); switch (family) { case AF_INET: -- 2.53.0