Skip to contentSkip to conversation

netfilter: conntrack: re-fetch conntrack after insertion

PATCH Applied Florian Westphal 2 participants 2 messages May 17, 2022 – May 19, 2022

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: conntrack: re-fetch conntrack after insertion

In case the conntrack is clashing, insertion can free skb->_nfct and set skb->_nfct to the already-confirmed entry.

This wasn't found before because the conntrack entry and the extension space used to free'd after an rcu grace period, plus the race needs events enabled to trigger.

Fixes 71d8c47fc653 ("netfilter: conntrack: introduce clash resolution on insertion race")
Fixes 2ad9d7747c10 ("netfilter: conntrack: free extension area immediately")
---
 include/net/netfilter/nf_conntrack_core.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
include/net/netfilter/nf_conntrack_core.h +6 -1
index 6406cfee34c2..37866c8386e2 100644
@@ -58,8 +58,13 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb)
 	int ret = NF_ACCEPT;
 
 	if (ct) {
-		if (!nf_ct_is_confirmed(ct))
+		if (!nf_ct_is_confirmed(ct)) {
 			ret = __nf_conntrack_confirm(skb);
+
+			if (ret == NF_ACCEPT)
+				ct = (struct nf_conn *)skb_nfct(skb);
+		}
+
 		if (ret == NF_ACCEPT && nf_ct_ecache_exist(ct))
 			nf_ct_deliver_cached_events(ct);
 	}
Signature · 1 line
2.35.1
maintainer Applied
#1 lore raw
Quoted 6 lines · Florian Westphal

In case the conntrack is clashing, insertion can free skb->_nfct and set skb->_nfct to the already-confirmed entry.

This wasn't found before because the conntrack entry and the extension space used to free'd after an rcu grace period, plus the race needs events enabled to trigger.

Applied, thanks