All of lore.kernel.org
 help / color / mirror / Atom feed
* [NETFILTER 2.4]: Fix deadlock on NAT helper unload
@ 2006-09-14 20:57 Patrick McHardy
  2006-10-07  9:50 ` Willy Tarreau
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick McHardy @ 2006-09-14 20:57 UTC (permalink / raw)
  To: David S. Miller; +Cc: Netfilter Development Mailinglist

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1170 bytes --]

[NETFILTER]: Fix deadlock on NAT helper unload

When a NAT helper is unlocked conntrack/NAT may deadlock because of
the following lock sequence:

.. ip_nat_helper_unregister
-> ip_ct_selective_cleanup
-> get_next_corpse		(ip_conntrack_lock)
-> kill_helper			(ip_nat_lock)

.. ip_nat_fn			(ip_nat_lock)
-> ip_nat_setup_info
-> ip_conntrack_alter_reply	(ip_conntrack_lock)

Taking ip_nat_lock in kill_helper() is unnecessary since the helper assigned
to a connection is immutable and new connections can't have the helper that
is beeing unloaded assigned since it is already removed from the global list.

Reported by <doublefacer007@gmail.com>.

Signed-off-by: Patrick McHardy <kaber@trash.net>

--- a/net/ipv4/netfilter/ip_nat_helper.c	2006-09-03 16:41:53.000000000 +0200
+++ b/net/ipv4/netfilter/ip_nat_helper.c	2006-09-03 16:42:04.000000000 +0200
@@ -522,13 +522,7 @@
 static int
 kill_helper(const struct ip_conntrack *i, void *helper)
 {
-	int ret;
-
-	READ_LOCK(&ip_nat_lock);
-	ret = (i->nat.info.helper == helper);
-	READ_UNLOCK(&ip_nat_lock);
-
-	return ret;
+	return (i->nat.info.helper == helper);
 }
 
 void ip_nat_helper_unregister(struct ip_nat_helper *me)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-10-08  4:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-14 20:57 [NETFILTER 2.4]: Fix deadlock on NAT helper unload Patrick McHardy
2006-10-07  9:50 ` Willy Tarreau
2006-10-08  4:44   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.