Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: sched: sch_multiq: fix possible OOB write in multiq_tune()

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>

authored by

Hangyu Hua and committed by
David S. Miller
affc18fd 491aee89

+1 -1
+1 -1
net/sched/sch_multiq.c
··· 185 185 186 186 qopt->bands = qdisc_dev(sch)->real_num_tx_queues; 187 187 188 - removed = kmalloc(sizeof(*removed) * (q->max_bands - q->bands), 188 + removed = kmalloc(sizeof(*removed) * (q->max_bands - qopt->bands), 189 189 GFP_KERNEL); 190 190 if (!removed) 191 191 return -ENOMEM;