Skip to contentSkip to conversation

Fix a deadlock in new_conntrack

PATCH In review Pablo Neira 2 participants 3 messages Aug 1, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 5/7 Fix a deadlock in new_conntrack

Fix a deadlock during conntrack creation. ip_conntrack_lock is unlocked twice.

net/ipv4/netfilter/ip_conntrack_netlink.c +5 -6
Index: netfilter-2.6.14/net/ipv4/netfilter/ip_conntrack_netlink.c
===================================================================
@@ -1094,13 +1094,12 @@
 		err = -ENOENT;
 		if (nlh->nlmsg_flags & NLM_F_CREATE)
 			err = ctnetlink_create_conntrack(cda, &otuple, &rtuple);
+		return err;
+	}
+	/* we only allow nat config for new conntracks */
+	if (cda[CTA_NAT-1]) {
+		err = -EINVAL;
 		goto out_unlock;
-	} else {
-		/* we only allow nat config for new conntracks */
-		if (cda[CTA_NAT-1]) {
-			err = -EINVAL;
-			goto out_unlock;
-		}
 	}
 
 	/* We manipulate the conntrack inside the global conntrack table lock,
#1 lore raw
Quoted 2 lines · Pablo Neira

Fix a deadlock during conntrack creation. ip_conntrack_lock is unlocked twice.

Please keep the exit paths at the end by adding a out: label.

Quoted 25 lines

------------------------------------------------------------------------

Index: netfilter-2.6.14/net/ipv4/netfilter/ip_conntrack_netlink.c
===================================================================

net/ipv4/netfilter/ip_conntrack_netlink.c +5 -6
@@ -1094,13 +1094,12 @@
 		err = -ENOENT;
 		if (nlh->nlmsg_flags & NLM_F_CREATE)
 			err = ctnetlink_create_conntrack(cda, &otuple, &rtuple);
+		return err;
+	}
+	/* we only allow nat config for new conntracks */
+	if (cda[CTA_NAT-1]) {
+		err = -EINVAL;
 		goto out_unlock;
-	} else {
-		/* we only allow nat config for new conntracks */
-		if (cda[CTA_NAT-1]) {
-			err = -EINVAL;
-			goto out_unlock;
-		}
 	}
 
 	/* We manipulate the conntrack inside the global conntrack table lock,
#2 lore raw
Quoted 7 lines · Patrick McHardy
Quoted 2 lines · Pablo Neira

Fix a deadlock during conntrack creation. ip_conntrack_lock is unlocked twice.

Please keep the exit paths at the end by adding a out: label.

Don't bother, they aren't at the end right now :)