* [PATCH nf] netfilter: conntrack: skip identical origin tuple in same zone only
@ 2021-02-05 11:56 Florian Westphal
2021-02-09 16:39 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2021-02-05 11:56 UTC (permalink / raw)
To: netfilter-devel; +Cc: 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.
Fixes: 4e35c1cb9460240 ("netfilter: nf_nat: skip nat clash resolution for same-origin entries")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
I have a selftest to trigger this bug, but it depends on
https://patchwork.ozlabs.org/project/netfilter-devel/patch/20210203165707.21781-4-fw@strlen.de/
and
https://patchwork.ozlabs.org/project/netfilter-devel/patch/20210203165707.21781-5-fw@strlen.de/
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(-)
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 234b7cab37c3..ff0168736f6e 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -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);
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf] netfilter: conntrack: skip identical origin tuple in same zone only
2021-02-05 11:56 [PATCH nf] netfilter: conntrack: skip identical origin tuple in same zone only Florian Westphal
@ 2021-02-09 16:39 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2021-02-09 16:39 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
On Fri, Feb 05, 2021 at 12:56:43PM +0100, Florian Westphal wrote:
> 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.
>
> Fixes: 4e35c1cb9460240 ("netfilter: nf_nat: skip nat clash resolution for same-origin entries")
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
> I have a selftest to trigger this bug, but it depends on
> https://patchwork.ozlabs.org/project/netfilter-devel/patch/20210203165707.21781-4-fw@strlen.de/
> and
> https://patchwork.ozlabs.org/project/netfilter-devel/patch/20210203165707.21781-5-fw@strlen.de/
>
> so I will only send it once a new nft release with those patches is
> out.
Looking into these patches now.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-09 16:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-05 11:56 [PATCH nf] netfilter: conntrack: skip identical origin tuple in same zone only Florian Westphal
2021-02-09 16:39 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).