* [PATCH net v2 1/2] xfrm: fix IPv6 first-fragment protocol decode
2026-11-03 22:58 [PATCH net v2 0/2] xfrm: fix IPv6 atomic fragment policy handling Jérémy Jean
@ 2026-11-03 22:58 ` Jérémy Jean
2026-11-03 22:58 ` [PATCH net v2 2/2] xfrm: fix selector matching for IPv6 atomic fragments Jérémy Jean
2026-11-03 23:02 ` [PATCH net v2 0/2] xfrm: fix IPv6 atomic fragment policy handling netdev-bot+sinfo
2 siblings, 0 replies; 4+ messages in thread
From: Jérémy Jean @ 2026-11-03 22:58 UTC (permalink / raw)
To: Steffen Klassert, Herbert Xu, David S. Miller
Cc: netdev, linux-kernel, Jérémy Jean, stable
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>
---
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 9ea60c7717ff8..bda5100c9fdbf 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -3480,23 +3480,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;
@@ -3507,10 +3513,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.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH net v2 2/2] xfrm: fix selector matching for IPv6 atomic fragments
2026-11-03 22:58 [PATCH net v2 0/2] xfrm: fix IPv6 atomic fragment policy handling Jérémy Jean
2026-11-03 22:58 ` [PATCH net v2 1/2] xfrm: fix IPv6 first-fragment protocol decode Jérémy Jean
@ 2026-11-03 22:58 ` Jérémy Jean
2026-11-03 23:02 ` [PATCH net v2 0/2] xfrm: fix IPv6 atomic fragment policy handling netdev-bot+sinfo
2 siblings, 0 replies; 4+ messages in thread
From: Jérémy Jean @ 2026-11-03 22:58 UTC (permalink / raw)
To: Steffen Klassert, Herbert Xu, David S. Miller
Cc: netdev, linux-kernel, Jérémy Jean, stable
Commit 7e3a42a12c4b ("xfrm6: handling fragment") stopped decoding IPv6
selector fields after a Fragment header. That is correct for real
fragments because later fragments do not carry those fields, yet an
atomic fragment is different because it contains the complete datagram,
which allows XFRM to read its ports, ICMPv6 type and code, and GRE key.
Leaving those fields zero lets a plaintext atomic fragment miss a policy
that matches on one of them.
Leave ports, ICMPv6 type and code, and GRE key unset for real
fragments. For atomic fragments, treat the packet as a complete datagram
during IPv6 session decoding and recover the ports at the transport
offset found by the flow dissector.
Fixes: 7e3a42a12c4b ("xfrm6: handling fragment")
Cc: stable@vger.kernel.org
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
net/xfrm/xfrm_policy.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index bda5100c9fdbf..24470dbd82639 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -3526,9 +3526,25 @@ int __xfrm_decode_session(struct net *net, struct sk_buff *skb, struct flowi *fl
decode_session4(&flkeys, fl, reverse);
break;
#if IS_ENABLED(CONFIG_IPV6)
- case AF_INET6:
+ case AF_INET6: {
+ struct frag_hdr _fh, *fh;
+ unsigned int offset = 0;
+
+ if ((flkeys.control.flags & FLOW_DIS_IS_FRAGMENT) &&
+ ipv6_find_hdr(skb, &offset, NEXTHDR_FRAGMENT,
+ NULL, NULL) == NEXTHDR_FRAGMENT) {
+ fh = skb_header_pointer(skb, offset, sizeof(_fh), &_fh);
+ if (fh && !(fh->frag_off & htons(IP6_OFFSET | IP6_MF))) {
+ flkeys.control.flags &= ~FLOW_DIS_IS_FRAGMENT;
+ flkeys.ports.ports = skb_flow_get_ports(skb,
+ flkeys.control.thoff,
+ flkeys.basic.ip_proto,
+ NULL, 0);
+ }
+ }
decode_session6(&flkeys, fl, reverse);
break;
+ }
#endif
default:
return -EAFNOSUPPORT;
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net v2 0/2] xfrm: fix IPv6 atomic fragment policy handling
2026-11-03 22:58 [PATCH net v2 0/2] xfrm: fix IPv6 atomic fragment policy handling Jérémy Jean
2026-11-03 22:58 ` [PATCH net v2 1/2] xfrm: fix IPv6 first-fragment protocol decode Jérémy Jean
2026-11-03 22:58 ` [PATCH net v2 2/2] xfrm: fix selector matching for IPv6 atomic fragments Jérémy Jean
@ 2026-11-03 23:02 ` netdev-bot+sinfo
2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-03 23:02 UTC (permalink / raw)
To: Jérémy Jean
Cc: Steffen Klassert, Herbert Xu, David S. Miller, netdev, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by code inspection). If it was triggered please include
the symptoms, like the stack trace or error messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread