Skip to contentSkip to conversation

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

PATCH Applied Hangyu Hua 3 participants 3 messages Jun 3, 2024 – Jun 5, 2024

Subsystems (3)
lore
Share & tools
lore

Hangyu Hua

author
#0 lore raw

PATCH 1/1 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")
---
 net/sched/sch_multiq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_multiq.c +1 -1
index 79e93a19d5fa..06e03f5cd7ce 100644
@@ -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;
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Hangyu Hua

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")

Looks good to me.

Thanks.

#2 lore raw
In reply to Hangyu Hua
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Mon, 3 Jun 2024 15:13:03 +0800 you wrote:

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")

[...]

Here is the summary with links:
- net: sched: sch_multiq: fix possible OOB write in multiq_tune()

    https://git.kernel.org/netdev/net/c/affc18fdc694

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html