Skip to contentSkip to conversation

net_sched: fix estimator lock selection for mq child qdiscs

PATCH Applied Patrick McHardy 2 participants 2 messages Sep 9, 2009 – Sep 10, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

commit d0a936694984bfd8bcd56cdddbbe1f077be7f277

Author: Patrick McHardy <[email protected]>
Date:   Wed Sep 9 17:50:10 2009 +0200

net_sched: fix estimator lock selection for mq child qdiscs

When new child qdiscs are attached to the mq qdisc, they are actually attached as root qdiscs to the device queues. The lock selection for new estimators incorrectly picks the root lock of the existing and to be replaced qdisc, which results in a use-after-free once the old qdisc has been destroyed.

Mark mq qdisc instances with a new flag and treat qdiscs attached to mq as children similar to regular root qdiscs.

Additionally prevent estimators from being attached to the mq qdisc itself since it only updates its byte and packet counters during dumps.

include/net/sch_generic.h +1 -0
index 9c69585..88eb9de 100644
@@ -46,6 +46,7 @@ struct Qdisc
 #define TCQ_F_THROTTLED		2
 #define TCQ_F_INGRESS		4
 #define TCQ_F_CAN_BYPASS	8
+#define TCQ_F_MQROOT		16
 #define TCQ_F_WARN_NONWC	(1 << 16)
 	int			padded;
 	struct Qdisc_ops	*ops;
net/sched/sch_api.c +26 -16

90 lines not on this page · raw message

net/sched/sch_mq.c +1 -0
index c84dec9..dd5ee02 100644
@@ -64,6 +64,7 @@ static int mq_init(struct Qdisc *sch, struct nlattr *opt)
 		priv->qdiscs[ntx] = qdisc;
 	}
 
+	sch->flags |= TCQ_F_MQROOT;
 	return 0;
 
 err:
maintainer Applied
#1 lore raw

From: Patrick McHardy <[email protected]>
Date: Wed, 09 Sep 2009 17:59:01 +0200

Quoted 8 lines

net_sched: fix estimator lock selection for mq child qdiscs

When new child qdiscs are attached to the mq qdisc, they are actually attached as root qdiscs to the device queues. The lock selection for new estimators incorrectly picks the root lock of the existing and to be replaced qdisc, which results in a use-after-free once the old qdisc has been destroyed.

Quoted 7 lines

Mark mq qdisc instances with a new flag and treat qdiscs attached to mq as children similar to regular root qdiscs.

Additionally prevent estimators from being attached to the mq qdisc itself since it only updates its byte and packet counters during dumps.

Applied, thanks!