]> git.karo-electronics.de Git - karo-tx-linux.git/commit
NET_SCHED: Fix fallout from dev->qdisc RCU change
authorPatrick McHardy <kaber@trash.net>
Tue, 10 Oct 2006 04:16:11 +0000 (21:16 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 13 Oct 2006 20:23:20 +0000 (13:23 -0700)
commit5f804c752ba4e4e85457bf0e4da9f8521720328b
treeb7646feea14b3711d5c217e7feed71b7b258b991
parente478bec0ba0a83a48a0f6982934b6de079e7e6b3
NET_SCHED: Fix fallout from dev->qdisc RCU change

The move of qdisc destruction to a rcu callback broke locking in the
entire qdisc layer by invalidating previously valid assumptions about
the context in which changes to the qdisc tree occur.

The two assumptions were:

- since changes only happen in process context, read_lock doesn't need
  bottem half protection. Now invalid since destruction of inner qdiscs,
  classifiers, actions and estimators happens in the RCU callback unless
  they're manually deleted, resulting in dead-locks when read_lock in
  process context is interrupted by write_lock_bh in bottem half context.

- since changes only happen under the RTNL, no additional locking is
  necessary for data not used during packet processing (f.e. u32_list).
  Again, since destruction now happens in the RCU callback, this assumption
  is not valid anymore, causing races while using this data, which can
  result in corruption or use-after-free.

Instead of "fixing" this by disabling bottem halfs everywhere and adding
new locks/refcounting, this patch makes these assumptions valid again by
moving destruction back to process context. Since only the dev->qdisc
pointer is protected by RCU, but ->enqueue and the qdisc tree are still
protected by dev->qdisc_lock, destruction of the tree can be performed
immediately and only the final free needs to happen in the rcu callback
to make sure dev_queue_xmit doesn't access already freed memory.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/core/dev.c
net/sched/cls_api.c
net/sched/sch_api.c
net/sched/sch_generic.c