]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jul 2024 07:08:11 +0000 (09:08 +0200)
[ Upstream commit affc18fdc694190ca7575b9a86632a73b9fe043d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sched/sch_multiq.c

index 1330ad2249317ccfdb81777c5ac4c56f3f500a64..b822d3e74637d349f1a42eab41f7de9d3921d0b4 100644 (file)
@@ -186,7 +186,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;