Skip to contentSkip to conversation

netfilter: ctnetlink: fix race between delete and timeout expiration

PATCH Applied [email protected] 2 participants 2 messages Mar 16, 2012 – Mar 17, 2012

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 netfilter: ctnetlink: fix race between delete and timeout expiration

From: Pablo Neira Ayuso <[email protected]>

Kerin Millar reported hardlockups while running `conntrackd -c' in a busy firewall. That system (with several processors) was acting as backup in a primary-backup setup.

After several tries, I found a race condition between the deletion operation of ctnetlink and timeout expiration. This patch fixes this problem.

---
 net/netfilter/nf_conntrack_netlink.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
net/netfilter/nf_conntrack_netlink.c +12 -11
index 1068769..b49da6c 100644
@@ -943,20 +943,21 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
 		}
 	}
 
-	if (nf_conntrack_event_report(IPCT_DESTROY, ct,
-				      NETLINK_CB(skb).pid,
-				      nlmsg_report(nlh)) < 0) {
+	if (del_timer(&ct->timeout)) {
+		if (nf_conntrack_event_report(IPCT_DESTROY, ct,
+					      NETLINK_CB(skb).pid,
+					      nlmsg_report(nlh)) < 0) {
+			nf_ct_delete_from_lists(ct);
+			/* we failed to report the event, try later */
+			nf_ct_insert_dying_list(ct);
+			nf_ct_put(ct);
+			return 0;
+		}
+		/* death_by_timeout would report the event again */
+		set_bit(IPS_DYING_BIT, &ct->status);
 		nf_ct_delete_from_lists(ct);
-		/* we failed to report the event, try later */
-		nf_ct_insert_dying_list(ct);
 		nf_ct_put(ct);
-		return 0;
 	}
-
-	/* death_by_timeout would report the event again */
-	set_bit(IPS_DYING_BIT, &ct->status);
-
-	nf_ct_kill(ct);
 	nf_ct_put(ct);
 
 	return 0;
Signature · 1 line
1.7.2.5
maintainer Applied
#1 lore raw

From: [email protected]
Date: Fri, 16 Mar 2012 13:00:34 +0100

Quoted 6 lines

From: Pablo Neira Ayuso <[email protected]>

Kerin Millar reported hardlockups while running `conntrackd -c' in a busy firewall. That system (with several processors) was acting as backup in a primary-backup setup.

Quoted 7 lines

After several tries, I found a race condition between the deletion operation of ctnetlink and timeout expiration. This patch fixes this problem.

Applied, thanks.