๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25796

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

#25796
From: netdev-bot+sashiko
Date: Wed, 02 Dec 2026 13:12
86 lines
10948 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message describes the bug and the fix only for inbound
  policy lookup of IPv6 atomic fragments.

--

xfrm: fix IPv6 first-fragment protocol decode

This patch sets FLOW_DISSECTOR_F_PARSE_1ST_FRAG for IPv6 in
__xfrm_decode_session(). With that flag, the flow dissector walks past
the Fragment header of a first fragment to reach the real upper-layer
protocol. It also stops decode_session6() from filling the port, ICMPv6
and GRE selector fields when the packet is a fragment.

> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index 6edf60242a80f..6baff3f797f8c 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c

[ ... ]

> @@ -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;

[Severity: Low]
This isn't a bug, but should the commit message describe the full
impact of this change? The message says:

    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.

Every AF_INET6 caller of __xfrm_decode_session() now gets the new flag,
not only the inbound path. In __skb_flow_dissect(), the NEXTHDR_FRAGMENT
case continues for any first fragment and does not check the M bit:

net/core/flow_dissector.c:__skb_flow_dissect() {
    ...
		if (!(fh->frag_off & htons(IP6_OFFSET))) {
			key_control->flags |= FLOW_DIS_FIRST_FRAG;
			if (flags & FLOW_DISSECTOR_F_PARSE_1ST_FRAG) {
				fdret = FLOW_DISSECT_RET_IPPROTO_AGAIN;
    ...
}

Consider a router without conntrack defrag that forwards a non-atomic
first fragment (offset 0, M=1) with a Destination Options header after
the Fragment header. That packet now reaches both policy lookups through
this decoder:

ip6_forward()
    xfrm6_policy_check(NULL, XFRM_POLICY_FWD, skb)
        __xfrm_decode_session()
    xfrm6_route_forward(skb)
        __xfrm_decode_session()

Before this patch, ip_proto came out as the Fragment header's nexthdr
(60 for DSTOPTS), so FWD or OUT policies with a protocol selector did
not match. After this patch they see the real upper-layer protocol.

Since this is Cc: stable, could the message also say that FWD and
outbound IPsec policy selection for forwarded non-atomic first fragments
changes too?

>  	__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:

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201124252.1163254-2-steffen.klassert%40secunet.com
Technical Details
Message-ID: <179621714878.3146.17309683097656909324@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375797-linux-kernel-netdev=dewy.ru
References: <20261201124252.1163254-11-steffen.klassert@secunet.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375797-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH 10/22] xfrm: fix IPv6 first-fragment protocol decode
Date: Wed, 02 Dec 2026 13:12:28 +0000
Organization: Usenet Network
Message-ID: <179621714878.3146.17309683097656909324@kernel.org>
References: <20261201124252.1163254-11-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="1976880"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0ojjNWsOTSFQD9mPvA0yP1EeFW8= sha256:Q9LfWpW28RkPLCSVjmyMSEIH2P0c8MIU76rFi5ajOyU=
	sha1:JnZ/d3KEsrcgH4v7peu9xT+aTLA= sha256:lMW6SkeIUtHEHwm7ZbdtyzhP5AiGf9R9ua8dEresj5Y=
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 A22FB117642; Wed,  2 Dec 2026 16:12:48 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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=kernel.org
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 VAas2gtLdz-J;
	Wed,  2 Dec 2026 16:12:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375797-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 915B6117641; Wed,  2 Dec 2026 16:12:33 +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 0EE4F2A51E; Wed,  2 Dec 2026 13:12:31 +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=1796217150;
	b=HPCyK1r007xzcHSSeXZDvMwIlA8BEYIluqcsAVJEWHdthHI/898dFUUaRFUaABsNidS/
	 tlQdHBGx8yOqC9z24wV2LBD1N0ZK6hTm8rL7CkSy/+BiKqY6W1YAK6qFO3RpDT+uisuyg
	 wBjhT9mQYIVUFKBt9lB2myoJBYHJCxdcES5vl2K+72OrbSDlmqY+VYanlISkt0HX2K9J3
	 /qtRtXEE/4c3UFhkb2RP8qyI/Gzwu0bBPlTOXWqQV5G1DXCD3Xl2e/aAZi1tPY9roWHOp
	 G9shyTf6kQcNVnT//EA4sOWYUtv3zi6eXSaYsGVhfpAPhzccgQDDEUgLF//A04316DA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796217150;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=nDXvDsECoCsmsAaoyiRJXQtlbIiWQ7v1dlE5YNWKhEg=;
	b=s6uN09ILt/T/ZAtx57IVNVI3VzfQOeusVWRViNVkbuYT0giahpCeWFLbGFpOd/CMLDTz
	 tq7G7jMsIR5JXQBuTMx5fLgcEzSnhepEEvAPpPwVHR/pAMCMcl4jPlmyrhuKck0W2D4HW
	 scsE+x80yLMfOziglTasr+18zQh1vFszjOVLGEmjyVC4JiP0Uh8dBDxnzp0f2EH2UK8AI
	 lzEEBtLE3yCOm1GTctfdVxn9iJoQyYZe2DwyaAs3ZljSMFAQpJiymoG/stu80FyXvfSa3
	 4J6lmsN6PSCYRDhkUBsylP7BV2owwva6IrloG2uouo6FlrqM1fX2fL+n2VfjZMxc20w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GKRSUug0;
	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 8CAEB606A31A;
	Wed,  2 Dec 2026 13:12:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GKRSUug0
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796217149;
	b=igD7PPcOjEqJoyuyr8OH0GjXYcJn3nwZ3ONUvupdPCK8oa4cd3Y7e+wPxMI9HyaTV1A7
	 MR3fwMyoWFGOJAb7m8XnhWOYJHXFLxy7f8EphV3KTM3XnZVerCnJswoBvFvoNGkD0KjfC
	 G1NgiX40fCTG9CrqFeEzM9o11ududjYFBVisbtzTrPQ+C74SOxKfJaqyMyOAKesbu0G8P
	 1iwiJYWsSSyXFrSgHzZaRFeGoOEjAELxcsdJPSqPyWPouBPLcUjQRZHSL8+d8YTNIsWbr
	 SCHhlG8FtX+6DtmhAYy5r7Z1l8ybyHVfZG2p8yA9ECoWlkLOzZfrgtgMVVsu4Mb9dhQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796217149;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=nDXvDsECoCsmsAaoyiRJXQtlbIiWQ7v1dlE5YNWKhEg=;
	b=t2xo1waMNObJLMkMh01DDsDPfqvp2xy8GG7g29ShbukKRBv4p8p3EbpobSZu/F06lflB
	 MSUM9cQhDL4g+jK5G2fPlJegtVG4cxE8UhD+4uugaUZnfNRgk646XIQ5nweXVRaveg4tL
	 rXJvjX5P2Xo1CRYnqnPG/0WfSQt1nSDOnmM/K2m/HwZFcbRJPDRFyYLsqyniZAkCbGCoc
	 jetmTqmBYx/ajDct5qXOnchggNBhMTdmxquNH3KESXxEh9bkY5OFW6ivp5FO8Gn6D24iM
	 AevRFpGDB5M054FCSltSgSIUqeueV0HsftM3MkUj0LAsZ4/bhz6vL9/3cQrRWx2CakQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GKRSUug0;
	arc=none smtp.remote-ip=100.103.45.18
X-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 AEC77606A322
	for <netdev@vger.kernel.org>; Wed,  2 Dec 2026 13:12:29 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32AA71F00893;
	Wed,  2 Dec 2026 13:12:29 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796217149;
	bh=nDXvDsECoCsmsAaoyiRJXQtlbIiWQ7v1dlE5YNWKhEg=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=GKRSUug0Y+LYYSRHcWD5KV/y23btu0GMxF3KCEPJ1a2hE5pACRpd91sWz+2FOmROw
	 4LV0w0NQCvDEX/ISYI6LWcRTKVgTRrTfVZvHzSK/X0cNH5o7iJCMRkkMpY6otJIQKm
	 fv6b9N6GYsipxGY7H+d8Qn/PjkSPE524p8Drl0Mh1UcN1UWi2nLLfEw6xGd+MIXpVV
	 rr6kjwvsOFMPsZbT2QOOJATPkPov0MR985IVdWEW4NMjTqkGHeabYmYwk47vFV6Je6
	 lwQxS39HEVbo5hJXf+3HeSSRYwAQkmChXEIEP2qsuyE7hdO8C5TtcjfUsF9PpOOBVY
	 6HGtGYdoxaarw==
X-Cc: davem@davemloft.net, kuba@kernel.org, herbert@gondor.apana.org.au,
 netdev@vger.kernel.org
X-In-Reply-To: <20261201124252.1163254-11-steffen.klassert@secunet.com>
X-sashiko-severity: Low
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