🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25249

[PATCH 10/22] xfrm: fix IPv6 first-fragment protocol decode

#25249
From: Steffen Klassert
Date: Tue, 01 Dec 2026 12:41
88 lines
12355 bytes
From: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>

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 <Jeremy.Jean@oss.cyber.gouv.fr>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 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
Technical Details
Message-ID: <20261201124252.1163254-11-steffen.klassert@secunet.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375039-linux-kernel-netdev=dewy.ru
References: <20261201124252.1163254-1-steffen.klassert@secunet.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375039-linux-kernel-netdev=dewy.ru
From: steffen.klassert@secunet.com (Steffen Klassert)
Newsgroups: linux.kernel.netdev
Subject: [PATCH 10/22] xfrm: fix IPv6 first-fragment protocol decode
Date: Tue, 1 Dec 2026 13:41:36 +0100
Organization: Usenet Network
Message-ID: <20261201124252.1163254-11-steffen.klassert@secunet.com>
References: <20261201124252.1163254-1-steffen.klassert@secunet.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1711729"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:RneHwnBwIgV3cwspOqKtAleoPN4= sha256:F0IIx9/rTLb1VOSo9UeJr91xz3UlakHQwwh73GUGZfw=
	sha1:+3YA5BkGYFb9eVzxpZAUZAj4qo8= sha256:ax0+K/SDhEgRs1IjpdA220FO7bzDEvQPw7l58qaqPrQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 6E96E11738A; Tue,  1 Dec 2026 15:44:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=secunet.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id EijWGE1yHMxL;
	Tue,  1 Dec 2026 15:44:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375039-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=secunet.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 13CB0117378; Tue,  1 Dec 2026 15:44:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id A834628BE9; Tue,  1 Dec 2026 12:44:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796129048;
	b=JfGJz9t2CnyKucWxwUEimrBBULK+JCvo7s/yNYVgoMjsOvrRtVYWtr/oyjAs/zhLeZAN
	 WL6p1Q2hp3YFfNF9vAQiDmb5G+bV1g+7wI3+P3tJTKOd6EeH64cIhH6pMziBn8gu1fLn6
	 YDEBa1V9Dt8dWkQcj6M/NeHl6cGMC9iibz7B1GUK4oj9K+xC714GjPYP/VW32UmdIo/ey
	 D/VeT+FTWYbE4/ICxogt7hsWifop4B2T6KdWMu4vg5q30KsYCbYDWnOWiytn4K28ETV1E
	 DrQvzFjzrHzi26VYBGmiUp383Z6La6Fz+amh+rwZnyI3Ig0IXXyEr7brDo7+Jxz6Jyg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796129048;
	h=X-Original-To:Received: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:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:X-ClientProxiedBy;
	bh=2J7lAXW3i+ZeednwbKHmmoxDDuYfvFAkaqyejEbmJyU=;
	b=WDJDsqNDfi5Rg14IF04GvC/EOUONWstJ4SD4wzIFP++XOxW4ief1EVKdvMbjD5xuMpRR
	 nSM1rZf0JMT4T/szNWn/qKY9mys6evMH4L2mHazi8LUTj3YO3PQW+FakVLRgSIWWanP+v
	 CN9ipicY/FUYQfuax0Y44xyzciZBcsvtxBYlPvxZkmfbv2vmZ4e876B3VYm8XVVVfkm3w
	 PFNjWrEJq+yr+uOs9jc0D2hYolPGO+XvglgQreDjUnLqoPeT4UgfPNVuZv0gmKZZT0GLC
	 1qzfPI7TUcLaz69nSJt4cNi8jNIMztqFRxZSSkTeabIjfYu83ji1wUm2r1uK0zT0vow==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=cUKjUNk4;
	dmarc=pass header.from=secunet.com;
	spf=pass smtp.mailfrom=secunet.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F0B9606A682;
	Tue,  1 Dec 2026 12:44:08 +0000 (UTC)
X-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
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.96.220.36
X-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==
X-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==
X-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
X-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 <netdev@vger.kernel.org>; Tue,  1 Dec 2026 12:44:06 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E1AB6606A681
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com
X-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
X-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)
X-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)
X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 14E99204D9
X-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==
X-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
X-Received: (nullmailer pid 1165790 invoked by uid 1000);
	Tue, 01 Dec 2026 12:43:55 -0000
X-CC: Herbert Xu <herbert@gondor.apana.org.au>, Steffen Klassert
	<steffen.klassert@secunet.com>, <netdev@vger.kernel.org>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261201124252.1163254-1-steffen.klassert@secunet.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-ClientProxiedBy: EXCH-03.secunet.de (10.32.0.183) To EXCH-01.secunet.de
 (10.32.0.171)