diff options
author | Patrick McHardy <kaber@trash.net> | 2006-09-27 19:45:45 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-28 21:01:50 -0400 |
commit | 85670cc1faa2e1472e4a423cbf0b5e3d55c5ba88 (patch) | |
tree | a5da67836995f1b04c844071db97608bc2c37b85 /net/sched/cls_api.c | |
parent | 787e0617e5176176c494a787f1b0a5248a3db568 (diff) |
[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>
Diffstat (limited to 'net/sched/cls_api.c')
-rw-r--r-- | net/sched/cls_api.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 7e14f14058e9..37a184021647 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -401,7 +401,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb) | |||
401 | if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL) | 401 | if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL) |
402 | return skb->len; | 402 | return skb->len; |
403 | 403 | ||
404 | read_lock_bh(&qdisc_tree_lock); | 404 | read_lock(&qdisc_tree_lock); |
405 | if (!tcm->tcm_parent) | 405 | if (!tcm->tcm_parent) |
406 | q = dev->qdisc_sleeping; | 406 | q = dev->qdisc_sleeping; |
407 | else | 407 | else |
@@ -458,7 +458,7 @@ errout: | |||
458 | if (cl) | 458 | if (cl) |
459 | cops->put(q, cl); | 459 | cops->put(q, cl); |
460 | out: | 460 | out: |
461 | read_unlock_bh(&qdisc_tree_lock); | 461 | read_unlock(&qdisc_tree_lock); |
462 | dev_put(dev); | 462 | dev_put(dev); |
463 | return skb->len; | 463 | return skb->len; |
464 | } | 464 | } |