From 43e8df19c830fcb86d4f3577df2f89f766570a43 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 14 Sep 2006 22:57:54 +0200 Subject: [PATCH] [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 . Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_nat_helper.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c index 6298d967..645f46d6 100644 --- a/net/ipv4/netfilter/ip_nat_helper.c +++ b/net/ipv4/netfilter/ip_nat_helper.c @@ -522,13 +522,7 @@ int ip_nat_helper_register(struct ip_nat_helper *me) static int kill_helper(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) -- 2.11.0