Skip to content

Commit 44d4775

Browse files
dcarattikuba-moo
authored andcommitted
net/sched: sch_taprio: reset child qdiscs before freeing them
syzkaller shows that packets can still be dequeued while taprio_destroy() is running. Let sch_taprio use the reset() function to cancel the advance timer and drop all skbs from the child qdiscs. Fixes: 5a781cc ("tc: Add support for configuring the taprio scheduler") Link: https://syzkaller.appspot.com/bug?id=f362872379bf8f0017fb667c1ab158f2d1e764ae Reported-by: syzbot+8971da381fb5a31f542d@syzkaller.appspotmail.com Signed-off-by: Davide Caratti <dcaratti@redhat.com> Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com> Link: https://lore.kernel.org/r/63b6d79b0e830ebb0283e020db4df3cdfdfb2b94.1608142843.git.dcaratti@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5b33afe commit 44d4775

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

net/sched/sch_taprio.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,21 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
15971597
return err;
15981598
}
15991599

1600+
static void taprio_reset(struct Qdisc *sch)
1601+
{
1602+
struct taprio_sched *q = qdisc_priv(sch);
1603+
struct net_device *dev = qdisc_dev(sch);
1604+
int i;
1605+
1606+
hrtimer_cancel(&q->advance_timer);
1607+
if (q->qdiscs) {
1608+
for (i = 0; i < dev->num_tx_queues && q->qdiscs[i]; i++)
1609+
qdisc_reset(q->qdiscs[i]);
1610+
}
1611+
sch->qstats.backlog = 0;
1612+
sch->q.qlen = 0;
1613+
}
1614+
16001615
static void taprio_destroy(struct Qdisc *sch)
16011616
{
16021617
struct taprio_sched *q = qdisc_priv(sch);
@@ -1607,7 +1622,6 @@ static void taprio_destroy(struct Qdisc *sch)
16071622
list_del(&q->taprio_list);
16081623
spin_unlock(&taprio_list_lock);
16091624

1610-
hrtimer_cancel(&q->advance_timer);
16111625

16121626
taprio_disable_offload(dev, q, NULL);
16131627

@@ -1954,6 +1968,7 @@ static struct Qdisc_ops taprio_qdisc_ops __read_mostly = {
19541968
.init = taprio_init,
19551969
.change = taprio_change,
19561970
.destroy = taprio_destroy,
1971+
.reset = taprio_reset,
19571972
.peek = taprio_peek,
19581973
.dequeue = taprio_dequeue,
19591974
.enqueue = taprio_enqueue,

0 commit comments

Comments
 (0)