fix array-index-out-of-bounds in taprio_change
Subsystems (4)
PATCH v2 1/1 fix array-index-out-of-bounds in taprio_change
From: Haimin Zhang <[email protected]>
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.
--- net/sched/sch_taprio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/sched/sch_taprio.c +3 -1
@@ -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],
Signature · 1 line
1.8.3.1
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Mon, 30 Aug 2021 11:47:01 +0800 you wrote:
From: Haimin Zhang <[email protected]>
syzbot report an array-index-out-of-bounds in
taprio_changeindex 16 is out of range for type '__u16[16]'
that's becausemqprio->num_tcis lager than TC_MAX_QUEUE,so we check the return value ofnetdev_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
Jakub Kicinski
maintainerQuoted 12 lines · On Mon, 30 Aug 2021 11:30:06 +0000 [email protected] wrote:
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 7 lines · On Mon, 30 Aug 2021 11:47:01 +0800 you wrote:
From: Haimin Zhang <[email protected]>
syzbot report an array-index-out-of-bounds in
taprio_changeindex 16 is out of range for type '__u16[16]'
that's becausemqprio->num_tcis lager than TC_MAX_QUEUE,so we check the return value ofnetdev_set_num_tc.
Quoted 7 lines
Quoted 1 line
[...]
Here is the summary with links:
- [V2] fix array-index-out-of-bounds intaprio_changehttps://git.kernel.org/netdev/net-next/c/efe487fce306You are awesome, thank you!
Oh, well...
Quoted 21 lines · Jakub Kicinski
Quoted 18 lines · On Mon, 30 Aug 2021 11:30:06 +0000 [email protected] wrote:
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Mon, 30 Aug 2021 11:47:01 +0800 you wrote:
From: Haimin Zhang <[email protected]>
syzbot report an array-index-out-of-bounds in
taprio_changeindex 16 is out of range for type '__u16[16]'
that's becausemqprio->num_tcis lager than TC_MAX_QUEUE,so we check the return value ofnetdev_set_num_tc.[...]
Here is the summary with links:
- [V2] fix array-index-out-of-bounds intaprio_changehttps://git.kernel.org/netdev/net-next/c/efe487fce306
Quoted 5 lines
Quoted 1 line
You are awesome, thank you!
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.