linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] fix array-index-out-of-bounds in taprio_change
@ 2021-08-30  3:47 tcs.kernel
  2021-08-30 11:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 4+ messages in thread
From: tcs.kernel @ 2021-08-30  3:47 UTC (permalink / raw)
  To: vinicius.gomes, jhs, xiyou.wangcong, jiri, davem, kuba, netdev,
	linux-kernel
  Cc: Haimin Zhang

From: Haimin Zhang <tcs_kernel@tencent.com>

syzbot report an array-index-out-of-bounds in taprio_change
index 16 is out of range for type '__u16 [16]'
that's because mqprio->num_tc is lager than TC_MAX_QUEUE,so we check
the return value of netdev_set_num_tc.

Reported-by: syzbot+2b3e5fb6c7ef285a94f6@syzkaller.appspotmail.com
Signed-off-by: Haimin Zhang <tcs_kernel@tencent.com>
---
 net/sched/sch_taprio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 9c79374..1ab2fc9 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1513,7 +1513,9 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
 	taprio_set_picos_per_byte(dev, q);
 
 	if (mqprio) {
-		netdev_set_num_tc(dev, mqprio->num_tc);
+		err = netdev_set_num_tc(dev, mqprio->num_tc);
+		if (err)
+			goto free_sched;
 		for (i = 0; i < mqprio->num_tc; i++)
 			netdev_set_tc_queue(dev, i,
 					    mqprio->count[i],
-- 
1.8.3.1


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

* Re: [PATCH V2] fix array-index-out-of-bounds in taprio_change
  2021-08-30  3:47 [PATCH V2] fix array-index-out-of-bounds in taprio_change tcs.kernel
@ 2021-08-30 11:30 ` patchwork-bot+netdevbpf
  2021-08-30 17:14   ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-08-30 11:30 UTC (permalink / raw)
  To: Haimin Zhang
  Cc: vinicius.gomes, jhs, xiyou.wangcong, jiri, davem, kuba, netdev,
	linux-kernel, tcs_kernel

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Mon, 30 Aug 2021 11:47:01 +0800 you wrote:
> From: Haimin Zhang <tcs_kernel@tencent.com>
> 
> syzbot report an array-index-out-of-bounds in taprio_change
> index 16 is out of range for type '__u16 [16]'
> that's because mqprio->num_tc is lager than TC_MAX_QUEUE,so we check
> the return value of netdev_set_num_tc.
> 
> [...]

Here is the summary with links:
  - [V2] fix array-index-out-of-bounds in taprio_change
    https://git.kernel.org/netdev/net-next/c/efe487fce306

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] 4+ messages in thread

* Re: [PATCH V2] fix array-index-out-of-bounds in taprio_change
  2021-08-30 11:30 ` patchwork-bot+netdevbpf
@ 2021-08-30 17:14   ` Jakub Kicinski
  2021-08-31  5:56     ` Cong Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2021-08-30 17:14 UTC (permalink / raw)
  To: Haimin Zhang
  Cc: vinicius.gomes, jhs, xiyou.wangcong, jiri, davem, netdev,
	linux-kernel, tcs_kernel

On Mon, 30 Aug 2021 11:30:06 +0000 patchwork-bot+netdevbpf@kernel.org
wrote:
> Hello:
> 
> This patch was applied to netdev/net-next.git (refs/heads/master):
> 
> On Mon, 30 Aug 2021 11:47:01 +0800 you wrote:
> > From: Haimin Zhang <tcs_kernel@tencent.com>
> > 
> > syzbot report an array-index-out-of-bounds in taprio_change
> > index 16 is out of range for type '__u16 [16]'
> > that's because mqprio->num_tc is lager than TC_MAX_QUEUE,so we check
> > the return value of netdev_set_num_tc.
> > 
> > [...]  
> 
> Here is the summary with links:
>   - [V2] fix array-index-out-of-bounds in taprio_change
>     https://git.kernel.org/netdev/net-next/c/efe487fce306
> 
> You are awesome, thank you!

https://lore.kernel.org/netdev/20210830091046.610ceb1b@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com/

Oh, well...

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

* Re: [PATCH V2] fix array-index-out-of-bounds in taprio_change
  2021-08-30 17:14   ` Jakub Kicinski
@ 2021-08-31  5:56     ` Cong Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Cong Wang @ 2021-08-31  5:56 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Haimin Zhang, Vinicius Costa Gomes, Jamal Hadi Salim, Jiri Pirko,
	David Miller, Linux Kernel Network Developers, LKML, tcs_kernel

On Mon, Aug 30, 2021 at 10:14 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Mon, 30 Aug 2021 11:30:06 +0000 patchwork-bot+netdevbpf@kernel.org
> wrote:
> > Hello:
> >
> > This patch was applied to netdev/net-next.git (refs/heads/master):
> >
> > On Mon, 30 Aug 2021 11:47:01 +0800 you wrote:
> > > From: Haimin Zhang <tcs_kernel@tencent.com>
> > >
> > > syzbot report an array-index-out-of-bounds in taprio_change
> > > index 16 is out of range for type '__u16 [16]'
> > > that's because mqprio->num_tc is lager than TC_MAX_QUEUE,so we check
> > > the return value of netdev_set_num_tc.
> > >
> > > [...]
> >
> > Here is the summary with links:
> >   - [V2] fix array-index-out-of-bounds in taprio_change
> >     https://git.kernel.org/netdev/net-next/c/efe487fce306
> >
> > You are awesome, thank you!
>
> https://lore.kernel.org/netdev/20210830091046.610ceb1b@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com/
>
> Oh, well...

I agree it is slightly better to make the check work in
taprio_parse_mqprio_opt(), but this patch is not bad either, we
need to check the return value of netdev_set_num_tc() for
completeness at least.

BTW, this patch should be landed in -net, not -net-next, as it
fixes a real bug reported by syzbot.

Thanks.

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

end of thread, other threads:[~2021-08-31  5:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30  3:47 [PATCH V2] fix array-index-out-of-bounds in taprio_change tcs.kernel
2021-08-30 11:30 ` patchwork-bot+netdevbpf
2021-08-30 17:14   ` Jakub Kicinski
2021-08-31  5:56     ` Cong Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).