Skip to contentSkip to conversation

netfilter: allow ipv6 fragments to arrive on different devices

PATCH Superseded Tom Hughes 2 participants 4 messages Aug 6, 2024

Subsystems (3)
lore
Share & tools
lore

Tom Hughes

author
#0 lore raw

PATCH 1/1 netfilter: allow ipv6 fragments to arrive on different devices

Commit 264640fc2c5f4 ("ipv6: distinguish frag queues by device for multicast and link-local packets") modified the ipv6 fragment reassembly logic to distinguish frag queues by device for multicast and link-local packets but in fact only the main reassembly code limits the use of the device to those address types and the netfilter reassembly code uses the device for all packets.

This means that if fragments of a packet arrive on different interfaces then netfilter will fail to reassemble them and the fragments will be expired without going any further through the filters.

---
 net/ipv6/netfilter/nf_conntrack_reasm.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv6/netfilter/nf_conntrack_reasm.c +4 -0
index 6f0844c9315d..4120e67a8ce6 100644
@@ -154,6 +154,10 @@ static struct frag_queue *fq_find(struct net *net, __be32 id, u32 user,
 	};
 	struct inet_frag_queue *q;
 
+	if (!(ipv6_addr_type(&hdr->daddr) & (IPV6_ADDR_MULTICAST |
+					    IPV6_ADDR_LINKLOCAL)))
+		key.iif = 0;
+
 	q = inet_frag_find(nf_frag->fqdir, &key);
 	if (!q)
 		return NULL;
Signature · 1 line
2.45.2
maintainer
#1 lore raw
Quoted 7 lines · Tom Hughes

Commit 264640fc2c5f4 ("ipv6: distinguish frag queues by device for multicast and link-local packets") modified the ipv6 fragment reassembly logic to distinguish frag queues by device for multicast and link-local packets but in fact only the main reassembly code limits the use of the device to those address types and the netfilter reassembly code uses the device for all packets.

Quoted 5 lines

This means that if fragments of a packet arrive on different interfaces then netfilter will fail to reassemble them and the fragments will be expired without going any further through the filters.

Probably:

Fixes 648700f76b03 ("inet: frags: use rhashtables for reassembly units")

?

Before this nf ipv6 reasm called ip6_frag_match() which ignored ifindex for types other than mcast/linklocal.

author
#2 lore raw
Quoted 14 lines · Florian Westphal
Quoted 7 lines · Tom Hughes

Commit 264640fc2c5f4 ("ipv6: distinguish frag queues by device for multicast and link-local packets") modified the ipv6 fragment reassembly logic to distinguish frag queues by device for multicast and link-local packets but in fact only the main reassembly code limits the use of the device to those address types and the netfilter reassembly code uses the device for all packets.

Quoted 5 lines

This means that if fragments of a packet arrive on different interfaces then netfilter will fail to reassemble them and the fragments will be expired without going any further through the filters.

Quoted 7 lines

Probably:

Fixes 648700f76b03 ("inet: frags: use rhashtables for reassembly units")

?

Before this nf ipv6 reasm called ip6_frag_match() which ignored ifindex for types other than mcast/linklocal.

Ah yes... I had found that change and knew it changed how the main reassembly code implemented the exception but hadn't realised that before that netfilter shared the comparison routine.

I'll update the patch to add that.

Tom

Signature · 2 lines
Tom Hughes ([email protected])
http://compton.nu/
author
#3 lore raw

PATCH v2 1/1 netfilter: allow ipv6 fragments to arrive on different devices

In reply to Tom Hughes

Commit 264640fc2c5f4 ("ipv6: distinguish frag queues by device for multicast and link-local packets") modified the ipv6 fragment reassembly logic to distinguish frag queues by device for multicast and link-local packets but in fact only the main reassembly code limits the use of the device to those address types and the netfilter reassembly code uses the device for all packets.

This means that if fragments of a packet arrive on different interfaces then netfilter will fail to reassemble them and the fragments will be expired without going any further through the filters.

Fixes 648700f76b03 ("inet: frags: use rhashtables for reassembly units")
---
 net/ipv6/netfilter/nf_conntrack_reasm.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv6/netfilter/nf_conntrack_reasm.c +4 -0
index 6f0844c9315d..4120e67a8ce6 100644
@@ -154,6 +154,10 @@ static struct frag_queue *fq_find(struct net *net, __be32 id, u32 user,
 	};
 	struct inet_frag_queue *q;
 
+	if (!(ipv6_addr_type(&hdr->daddr) & (IPV6_ADDR_MULTICAST |
+					    IPV6_ADDR_LINKLOCAL)))
+		key.iif = 0;
+
 	q = inet_frag_find(nf_frag->fqdir, &key);
 	if (!q)
 		return NULL;
Signature · 1 line
2.45.2