All of lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: steffen.klassert@secunet.com
Cc: davem@davemloft.net, kuba@kernel.org,
	herbert@gondor.apana.org.au, netdev@vger.kernel.org
Subject: Re: [PATCH 10/22] xfrm: fix IPv6 first-fragment protocol decode
Date: Wed, 02 Dec 2026 13:12:28 +0000	[thread overview]
Message-ID: <179621714878.3146.17309683097656909324@kernel.org> (raw)
In-Reply-To: <20261201124252.1163254-11-steffen.klassert@secunet.com>

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

  reply	other threads:[~2026-12-02 13:12 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 12:41 [PATCH 0/22] pull request (net): ipsec 2026-12-01 Steffen Klassert
2026-12-01 12:41 ` [PATCH 01/22] xfrm: ipcomp: account full fragment pages in truesize Steffen Klassert
2026-12-01 13:36   ` bot+bpf-ci
2026-12-01 12:41 ` [PATCH 02/22] xfrm: esp: reset outer TCP GSO metadata on espintcp input Steffen Klassert
2026-12-01 12:41 ` [PATCH 03/22] xfrm: keep the mode module pinned until destroy_state returns Steffen Klassert
2026-12-01 12:41 ` [PATCH 04/22] xfrm: serialize SA activation with state deletion Steffen Klassert
2026-12-01 12:41 ` [PATCH 05/22] xfrm: keep old state references until migration deletion completes Steffen Klassert
2026-12-01 12:41 ` [PATCH 06/22] xfrm: hold migrated states through rollback Steffen Klassert
2026-12-01 12:41 ` [PATCH 07/22] xfrm: check inner family via skb_dst for small_ipv6 DF clearing Steffen Klassert
2026-12-02 13:12   ` netdev-bot+sashiko
2026-12-01 12:41 ` [PATCH 08/22] xfrm: account XFRMA_MARK in xfrm_sa_len() Steffen Klassert
2026-12-01 12:41 ` [PATCH 09/22] xfrm: replay: Fix late packet handling with ESN crypto offload Steffen Klassert
2026-12-02 13:12   ` netdev-bot+sashiko
2026-12-01 12:41 ` [PATCH 10/22] xfrm: fix IPv6 first-fragment protocol decode Steffen Klassert
2026-12-02 13:12   ` netdev-bot+sashiko [this message]
2026-12-01 12:41 ` [PATCH 11/22] xfrm: fix selector matching for IPv6 atomic fragments Steffen Klassert
2026-12-02 13:12   ` netdev-bot+sashiko
2026-12-01 12:41 ` [PATCH 12/22] xfrm: espintcp: read the socket error queue for MSG_ERRQUEUE Steffen Klassert
2026-12-01 12:41 ` [PATCH 13/22] xfrm: iptfs: force a dst reference before queueing an skb Steffen Klassert
2026-12-01 13:36   ` bot+bpf-ci
2026-12-01 12:41 ` [PATCH 14/22] xfrm: espintcp: select receive path by skb protocol Steffen Klassert
2026-12-01 12:41 ` [PATCH 15/22] net: xfrm: interface: restore dst_orig on every xfrm interface Steffen Klassert
2026-12-02 13:12   ` netdev-bot+sashiko
2026-12-01 12:41 ` [PATCH 16/22] xfrm: iptfs: make room before copying a continuation in reassembly Steffen Klassert
2026-12-01 12:41 ` [PATCH 17/22] xfrm/compat: pass on the translated length of a socket policy Steffen Klassert
2026-12-01 12:41 ` [PATCH 18/22] xfrm: Give GC list nodes their own storage Steffen Klassert
2026-12-02 13:12   ` netdev-bot+sashiko
2026-12-01 12:41 ` [PATCH 19/22] xfrm: Serialize device state teardown Steffen Klassert
2026-12-02 13:12   ` netdev-bot+sashiko
2026-12-01 12:41 ` [PATCH 20/22] xfrm: Wait for an RCU grace period before freeing device state Steffen Klassert
2026-12-02 13:12   ` netdev-bot+sashiko
2026-12-01 12:41 ` [PATCH 21/22] Revert "xfrm: serialize state GC with device state flush" Steffen Klassert
2026-12-02 13:12   ` netdev-bot+sashiko
2026-12-01 12:41 ` [PATCH 22/22] xfrm: Serialize offload stats updates with x->lock Steffen Klassert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179621714878.3146.17309683097656909324@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.