]> www.infradead.org Git - users/hch/xfs.git/commitdiff
net: sched: sch_multiq: fix possible OOB write in multiq_tune()
authorHangyu Hua <hbh25y@gmail.com>
Mon, 3 Jun 2024 07:13:03 +0000 (15:13 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 5 Jun 2024 09:50:19 +0000 (10:50 +0100)
q->bands will be assigned to qopt->bands to execute subsequent code logic
after kmalloc. So the old q->bands should not be used in kmalloc.
Otherwise, an out-of-bounds write will occur.

Fixes: c2999f7fb05b ("net: sched: multiq: don't call qdisc_put() while holding tree lock")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Acked-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_multiq.c

index 79e93a19d5fabeb5ee91e20388d67ef019064064..06e03f5cd7ce182590c142e4c83f8d93f800b89e 100644 (file)
@@ -185,7 +185,7 @@ static int multiq_tune(struct Qdisc *sch, struct nlattr *opt,
 
        qopt->bands = qdisc_dev(sch)->real_num_tx_queues;
 
-       removed = kmalloc(sizeof(*removed) * (q->max_bands - q->bands),
+       removed = kmalloc(sizeof(*removed) * (q->max_bands - qopt->bands),
                          GFP_KERNEL);
        if (!removed)
                return -ENOMEM;