net: fix possible deadlock in sum_frag_mem_limit
authorEric Dumazet <edumazet@google.com>
Fri, 22 Feb 2013 07:43:35 +0000 (07:43 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 22 Feb 2013 20:10:19 +0000 (15:10 -0500)
Dave Jones reported a lockdep splat occurring in IP defrag code.

commit 6d7b857d541ecd1d (net: use lib/percpu_counter API for
fragmentation mem accounting) added a possible deadlock.

Because percpu_counter_sum_positive() needs to acquire
a lock that can be used from softirq, we need to disable BH
in sum_frag_mem_limit()

Reported-by: Dave Jones <davej@redhat.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/inet_frag.h

index 3f237db0a426ce1606587da6060ce1da5f306b60..76c3fe5ecc2e6ed9fcf1b81be7dbd3d3dc258d73 100644 (file)
@@ -114,7 +114,13 @@ static inline void init_frag_mem_limit(struct netns_frags *nf)
 
 static inline int sum_frag_mem_limit(struct netns_frags *nf)
 {
-       return percpu_counter_sum_positive(&nf->mem);
+       int res;
+
+       local_bh_disable();
+       res = percpu_counter_sum_positive(&nf->mem);
+       local_bh_enable();
+
+       return res;
 }
 
 static inline void inet_frag_lru_move(struct inet_frag_queue *q)