Commit 40ca54e3 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net_sched: gen_estimator: fix lockdep splat

syzbot reported a lockdep splat in gen_new_estimator() /
est_fetch_counters() when attempting to lock est->stats_lock.

Since est_fetch_counters() is called from BH context from timer
interrupt, we need to block BH as well when calling it from process
context.

Most qdiscs use per cpu counters and are immune to the problem,
but net/sched/act_api.c and net/netfilter/xt_RATEEST.c are using
a spinlock to protect their data. They both call gen_new_estimator()
while object is created and not yet alive, so this bug could
not trigger a deadlock, only a lockdep splat.

Fixes: 1c0d32fd ("net_sched: gen_estimator: complete rewrite of rate estimators")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
Acked-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 032dc41b
...@@ -159,7 +159,11 @@ int gen_new_estimator(struct gnet_stats_basic_packed *bstats, ...@@ -159,7 +159,11 @@ int gen_new_estimator(struct gnet_stats_basic_packed *bstats,
est->intvl_log = intvl_log; est->intvl_log = intvl_log;
est->cpu_bstats = cpu_bstats; est->cpu_bstats = cpu_bstats;
if (stats_lock)
local_bh_disable();
est_fetch_counters(est, &b); est_fetch_counters(est, &b);
if (stats_lock)
local_bh_enable();
est->last_bytes = b.bytes; est->last_bytes = b.bytes;
est->last_packets = b.packets; est->last_packets = b.packets;
old = rcu_dereference_protected(*rate_est, 1); old = rcu_dereference_protected(*rate_est, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment