From: Eric Dumazet <eduma...@google.com>

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 <da...@redhat.com>
Signed-off-by: Eric Dumazet <eduma...@google.com>
Cc: Jesper Dangaard Brouer <bro...@redhat.com>
---
 include/net/inet_frag.h |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index 3f237db..76c3fe5 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -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)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to