Skip to contentSkip to conversation

net: sched: sch: Fix off by one in htb_activate_prios()

PATCH Applied Dan Carpenter 5 participants 6 messages Feb 6, 2023 – Feb 8, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: sched: sch: Fix off by one in htb_activate_prios()

The > needs be >= to prevent an out of bounds access.

Fixes de5ca4c3852f ("net: sched: sch: Bounds check priority")
---
 net/sched/sch_htb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_htb.c +1 -1
index cc28e41fb745..92f2975b6a82 100644
@@ -433,7 +433,7 @@ static void htb_activate_prios(struct htb_sched *q, struct htb_class *cl)
 		while (m) {
 			unsigned int prio = ffz(~m);
 
-			if (WARN_ON_ONCE(prio > ARRAY_SIZE(p->inner.clprio)))
+			if (WARN_ON_ONCE(prio >= ARRAY_SIZE(p->inner.clprio)))
 				break;
 			m &= ~(1 << prio);
 
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 13 lines · Dan Carpenter

The > needs be >= to prevent an out of bounds access.

Fixes de5ca4c3852f ("net: sched: sch: Bounds check priority")
---
 net/sched/sch_htb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_htb.c +0 -0
index cc28e41fb745..92f2975b6a82 100644

net/sched/sch_htb.c static void htb_activate_prios(struct htb_sched *q, struct htb_class *cl) · line 436

Quoted 5 lines
net/sched/sch_htb.c +1 -1
@@ -433,7 +433,7 @@ static void htb_activate_prios(struct htb_sched *q, struct htb_class *cl)
 		while (m) {
 			unsigned int prio = ffz(~m);
 
-			if (WARN_ON_ONCE(prio > ARRAY_SIZE(p->inner.clprio)))
+			if (WARN_ON_ONCE(prio >= ARRAY_SIZE(p->inner.clprio)))

Argh, whoops. Thanks Dan!

Signature · 1 line
Kees Cook
maintainer
#3 lore raw
In reply to Dan Carpenter
Quoted 1 line · On Mon, 6 Feb 2023 16:18:32 +0300 Dan Carpenter wrote:

Subject: [PATCH net-next] net: sched: sch: Fix off by one in htb_activate_prios()

Thanks for tagging but just to be sure - this is for net, right? (no need to repost)

Quoted 3 lines

The > needs be >= to prevent an out of bounds access.

Fixes de5ca4c3852f ("net: sched: sch: Bounds check priority")
#4 lore raw
Quoted 6 lines · Jakub Kicinski
Quoted 1 line · On Mon, 6 Feb 2023 16:18:32 +0300 Dan Carpenter wrote:

Subject: [PATCH net-next] net: sched: sch: Fix off by one in htb_activate_prios()

Thanks for tagging but just to be sure - this is for net, right? (no need to repost)

Yes. And I did verify before sending that it applied to net, but I still put net-next in the subject because I'm an idiot.

regards,
dan carpenter

#5 lore raw
In reply to Dan Carpenter
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 7 lines · On Mon, 6 Feb 2023 16:18:32 +0300 you wrote:

The > needs be >= to prevent an out of bounds access.

Fixes de5ca4c3852f ("net: sched: sch: Bounds check priority")
---
 net/sched/sch_htb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- [net-next] net: sched: sch: Fix off by one in htb_activate_prios()

    https://git.kernel.org/netdev/net/c/9cec2aaffe96

You are awesome, thank you!

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