Skip to content

Commit

Permalink
net: fix possible deadlock in sum_frag_mem_limit
Browse files Browse the repository at this point in the history
Dave Jones reported a lockdep splat occurring in IP defrag code.

commit 6d7b857 (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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Feb 22, 2013
1 parent e2f8d55 commit 4cfb048
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/net/inet_frag.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4cfb048

Please sign in to comment.