Skip to contentSkip to conversation

net/sched: sch_hfsc: Ensure inner classes have fsc curve

PATCH Applied Budimir Markovic 3 participants 3 messages Aug 24, 2023 – Aug 26, 2023

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

PATCH 1/1 net/sched: sch_hfsc: Ensure inner classes have fsc curve

HFSC assumes that inner classes have an fsc curve, but it is currently possible for classes without an fsc curve to become parents. This leads to bugs including a use-after-free.

Don't allow non-root classes without HFSC_FSC to become parents.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 net/sched/sch_hfsc.c | 4 ++++
 1 file changed, 4 insertions(+)
net/sched/sch_hfsc.c +4 -0
index 70b0c5873..d14cff8d4 100644
@@ -1012,6 +1012,10 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
 		if (parent == NULL)
 			return -ENOENT;
 	}
+	if (!(parent->cl_flags & HFSC_FSC) && parent != &q->root) {
+		NL_SET_ERR_MSG(extack, "Invalid parent - parent class must have FSC");
+		return -EINVAL;
+	}
 
 	if (classid == 0 || TC_H_MAJ(classid ^ sch->handle) != 0)
 		return -EINVAL;
Signature · 1 line
2.41.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Budimir Markovic

HFSC assumes that inner classes have an fsc curve, but it is currently possible for classes without an fsc curve to become parents. This leads to bugs including a use-after-free.

Don't allow non-root classes without HFSC_FSC to become parents.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

cheers,
jamal

Quoted 22 lines
---
 net/sched/sch_hfsc.c | 4 ++++
 1 file changed, 4 insertions(+)
net/sched/sch_hfsc.c +4 -1
index 70b0c5873..d14cff8d4 100644
@@ -1012,6 +1012,10 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
                if (parent == NULL)
                        return -ENOENT;
        }
+       if (!(parent->cl_flags & HFSC_FSC) && parent != &q->root) {
+               NL_SET_ERR_MSG(extack, "Invalid parent - parent class must have FSC");
+               return -EINVAL;
+       }
 
        if (classid == 0 || TC_H_MAJ(classid ^ sch->handle) != 0)
                return -EINVAL;
--

2.41.0

#2 lore raw
In reply to Budimir Markovic
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 11 lines · On Thu, 24 Aug 2023 01:49:05 -0700 you wrote:

HFSC assumes that inner classes have an fsc curve, but it is currently possible for classes without an fsc curve to become parents. This leads to bugs including a use-after-free.

Don't allow non-root classes without HFSC_FSC to become parents.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

[...]

Here is the summary with links:
- [net] net/sched: sch_hfsc: Ensure inner classes have fsc curve

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

You are awesome, thank you!

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