diff options
author | Eric Dumazet <edumazet@google.com> | 2013-02-22 02:43:35 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-02-22 15:10:19 -0500 |
commit | 4cfb04854d053e4d6391d7f84495f48082342362 (patch) | |
tree | c95cf3b428f797e0ee75defbe31dfabf6c6957bb /include/net | |
parent | e2f8d555ec04a0beb965ea76e3a150993e8f0436 (diff) |
net: fix possible deadlock in sum_frag_mem_limit
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>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/inet_frag.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index 3f237db0a426..76c3fe5ecc2e 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) | |||
114 | 114 | ||
115 | static inline int sum_frag_mem_limit(struct netns_frags *nf) | 115 | static inline int sum_frag_mem_limit(struct netns_frags *nf) |
116 | { | 116 | { |
117 | return percpu_counter_sum_positive(&nf->mem); | 117 | int res; |
118 | |||
119 | local_bh_disable(); | ||
120 | res = percpu_counter_sum_positive(&nf->mem); | ||
121 | local_bh_enable(); | ||
122 | |||
123 | return res; | ||
118 | } | 124 | } |
119 | 125 | ||
120 | static inline void inet_frag_lru_move(struct inet_frag_queue *q) | 126 | static inline void inet_frag_lru_move(struct inet_frag_queue *q) |