diff mbox series

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

Message ID 20230824084905.422-1-markovicbudimir@gmail.com (mailing list archive)
State Accepted
Commit b3d26c5702c7d6c45456326e56d2ccf3f103e60f
Delegated to: Netdev Maintainers
Headers show
Series [net] net/sched: sch_hfsc: Ensure inner classes have fsc curve | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1328 this patch: 1328
netdev/cc_maintainers warning 6 maintainers not CCed: kuba@kernel.org pabeni@redhat.com davem@davemloft.net xiyou.wangcong@gmail.com jiri@resnulli.us edumazet@google.com
netdev/build_clang success Errors and warnings before: 1351 this patch: 1351
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1351 this patch: 1351
netdev/checkpatch warning WARNING: line length of 86 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Budimir Markovic Aug. 24, 2023, 8:49 a.m. UTC
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")
Reported-by: Budimir Markovic <markovicbudimir@gmail.com>
Signed-off-by: Budimir Markovic <markovicbudimir@gmail.com>
---
 net/sched/sch_hfsc.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jamal Hadi Salim Aug. 24, 2023, 2:21 p.m. UTC | #1
On Thu, Aug 24, 2023 at 4:50 AM Budimir Markovic
<markovicbudimir@gmail.com> 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")
> Reported-by: Budimir Markovic <markovicbudimir@gmail.com>
> Signed-off-by: Budimir Markovic <markovicbudimir@gmail.com>

Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>

cheers,
jamal

> ---
>  net/sched/sch_hfsc.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
> index 70b0c5873..d14cff8d4 100644
> --- a/net/sched/sch_hfsc.c
> +++ b/net/sched/sch_hfsc.c
> @@ -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
>
patchwork-bot+netdevbpf@kernel.org Aug. 26, 2023, 2:10 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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")
> Reported-by: Budimir Markovic <markovicbudimir@gmail.com>
> Signed-off-by: Budimir Markovic <markovicbudimir@gmail.com>
> 
> [...]

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!
diff mbox series

Patch

diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 70b0c5873..d14cff8d4 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -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;