Skip to contentSkip to conversation

netfilter: conntrack: skip identical origin tuple in same zone only

PATCH Applied Florian Westphal 2 participants 2 messages Feb 5, 2021 – Feb 9, 2021

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: conntrack: skip identical origin tuple in same zone only

The origin skip check needs to re-test the zone. Else, we might skip a colliding tuple in the reply direction.

This only occurs when using 'directional zones' where origin tuples reside in different zones but the reply tuples share the same zone.

This causes the new conntrack entry to be dropped at confirmation time because NAT clash resolution was elided.

Fixes 4e35c1cb9460240 ("netfilter: nf_nat: skip nat clash resolution for same-origin entries")

---
I have a selftest to trigger this bug, but it depends on
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
and
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

so I will only send it once a new nft release with those patches is out.

 net/netfilter/nf_conntrack_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nf_conntrack_core.c +2 -1
index 234b7cab37c3..ff0168736f6e 100644
@@ -1229,7 +1229,8 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
 			 * Let nf_ct_resolve_clash() deal with this later.
 			 */
 			if (nf_ct_tuple_equal(&ignored_conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
-					      &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple))
+					      &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple) &&
+					      nf_ct_zone_equal(ct, zone, IP_CT_DIR_ORIGINAL))
 				continue;
 
 			NF_CT_STAT_INC_ATOMIC(net, found);
Signature · 1 line
2.26.2
maintainer Applied
#1 lore raw
Quoted 8 lines · Florian Westphal

The origin skip check needs to re-test the zone. Else, we might skip a colliding tuple in the reply direction.

This only occurs when using 'directional zones' where origin tuples reside in different zones but the reply tuples share the same zone.

This causes the new conntrack entry to be dropped at confirmation time because NAT clash resolution was elided.

Applied, thanks Florian.

Quoted 11 lines
Fixes 4e35c1cb9460240 ("netfilter: nf_nat: skip nat clash resolution for same-origin entries")

---
I have a selftest to trigger this bug, but it depends on
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
and
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

so I will only send it once a new nft release with those patches is out.

Looking into these patches now.