netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PKT_SCHED: Prevent destroying via RTM_DELTFILTER while classifying
@ 2004-12-10  1:43 Thomas Graf
  2004-12-10  2:08 ` Patrick McHardy
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Graf @ 2004-12-10  1:43 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

The classify function of every cls is invoked under BH and 
dev->queue_lock spinlock from dev_xmit. Hence to serialize destroying
the destroy function must be called under the spinlock as well. There
are 2 paths in which a classifier can be destroyed:

1) via the qdisc destroy cb calling tcf_destroy under
   qdisc_tree_lock from __qdisc_destroy (rcu callback)
      
2) via RTM_DELTFILTER in cls_api.c under no locks at all.

The first path seems ok, the initial qdisc destroy attempt is called
under the spinlock and thus serialized with the classify while
the list unlinking takes place and dev_xmit takes care of
the RCU callback, hence classify and all the callbacks needed
from process context cannot be found anymore.

The second path needs the spinlock to avoid destroying while
a classification is in progress. 2.4 probably needs the same fix,
I will cook one up if so.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

--- linux-2.6.10-rc2-bk13.orig/net/sched/cls_api.c	2004-11-30 14:01:12.000000000 +0100
+++ linux-2.6.10-rc2-bk13/net/sched/cls_api.c	2004-12-10 02:16:29.000000000 +0100
@@ -257,7 +257,9 @@
 			qdisc_unlock_tree(dev);
 
 			tfilter_notify(skb, n, tp, fh, RTM_DELTFILTER);
+			qdisc_lock_tree(dev);
 			tcf_destroy(tp);
+			qdisc_unlock_tree(dev);
 			err = 0;
 			goto errout;
 		}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-12-10 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-10  1:43 [PATCH] PKT_SCHED: Prevent destroying via RTM_DELTFILTER while classifying Thomas Graf
2004-12-10  2:08 ` Patrick McHardy
2004-12-10 12:29   ` Thomas Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).