The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] net: sched: sch_multiq: fix possible OOB write in multiq_tune()
@ 2024-06-03  7:13 Hangyu Hua
  2024-06-04 15:30 ` Cong Wang
  2024-06-05 10:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Hangyu Hua @ 2024-06-03  7:13 UTC (permalink / raw)
  To: jhs, xiyou.wangcong, jiri, davem, edumazet, kuba, pabeni, vladbu
  Cc: netdev, linux-kernel, 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")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
 net/sched/sch_multiq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c
index 79e93a19d5fa..06e03f5cd7ce 100644
--- a/net/sched/sch_multiq.c
+++ b/net/sched/sch_multiq.c
@@ -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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: sched: sch_multiq: fix possible OOB write in multiq_tune()
  2024-06-03  7:13 [PATCH] net: sched: sch_multiq: fix possible OOB write in multiq_tune() Hangyu Hua
@ 2024-06-04 15:30 ` Cong Wang
  2024-06-05 10:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Cong Wang @ 2024-06-04 15:30 UTC (permalink / raw)
  To: Hangyu Hua
  Cc: jhs, jiri, davem, edumazet, kuba, pabeni, vladbu, netdev,
	linux-kernel

On Mon, Jun 03, 2024 at 03:13:03PM +0800, Hangyu Hua 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")
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>

Looks good to me.

Acked-by: Cong Wang <cong.wang@bytedance.com>

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: sched: sch_multiq: fix possible OOB write in multiq_tune()
  2024-06-03  7:13 [PATCH] net: sched: sch_multiq: fix possible OOB write in multiq_tune() Hangyu Hua
  2024-06-04 15:30 ` Cong Wang
@ 2024-06-05 10:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-05 10:00 UTC (permalink / raw)
  To: Hangyu Hua
  Cc: jhs, xiyou.wangcong, jiri, davem, edumazet, kuba, pabeni, vladbu,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

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")
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-05 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-03  7:13 [PATCH] net: sched: sch_multiq: fix possible OOB write in multiq_tune() Hangyu Hua
2024-06-04 15:30 ` Cong Wang
2024-06-05 10:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox