Blame SOURCES/CVE-2023-4623.patch

835086
From e42a36dc8c4dfa5eb51abe028d5dbf7ccc1f5a6f Mon Sep 17 00:00:00 2001
835086
From: Joe Lawrence <joe.lawrence@redhat.com>
835086
Date: Mon, 27 Nov 2023 13:25:03 -0500
835086
Subject: [KPATCH CVE-2023-4623] kpatch fixes for CVE-2023-4623
835086
835086
Kernels:
835086
3.10.0-1160.92.1.el7
835086
3.10.0-1160.95.1.el7
835086
3.10.0-1160.99.1.el7
835086
3.10.0-1160.102.1.el7
835086
3.10.0-1160.105.1.el7
835086
835086
835086
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/63
835086
Changes since last build:
835086
[x86_64]:
835086
af_unix.o: changed function: unix_stream_sendpage
835086
sch_hfsc.o: changed function: hfsc_change_class
835086
835086
[ppc64le]:
835086
af_unix.o: changed function: unix_stream_sendpage
835086
835086
---------------------------
835086
835086
Modifications: none
835086
835086
commit 85dbd5b056f6c63f122abbf6b07974adb66c8c10
835086
Author: Davide Caratti <dcaratti@redhat.com>
835086
Date:   Tue Nov 21 18:08:36 2023 +0100
835086
835086
    net/sched: sch_hfsc: Ensure inner classes have fsc curve
835086
835086
    JIRA: https://issues.redhat.com/browse/RHEL-16458
835086
    CVE: CVE-2023-4623
835086
    Upstream Status: net.git commit b3d26c5702c7d6c45456326e56d2ccf3f103e60f
835086
835086
    commit b3d26c5702c7d6c45456326e56d2ccf3f103e60f
835086
    Author: Budimir Markovic <markovicbudimir@gmail.com>
835086
    Date:   Thu Aug 24 01:49:05 2023 -0700
835086
835086
        net/sched: sch_hfsc: Ensure inner classes have fsc curve
835086
835086
        HFSC assumes that inner classes have an fsc curve, but it is currently
835086
        possible for classes without an fsc curve to become parents. This leads
835086
        to bugs including a use-after-free.
835086
835086
        Don't allow non-root classes without HFSC_FSC to become parents.
835086
835086
        Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
835086
        Reported-by: Budimir Markovic <markovicbudimir@gmail.com>
835086
        Signed-off-by: Budimir Markovic <markovicbudimir@gmail.com>
835086
        Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
835086
        Link: https://lore.kernel.org/r/20230824084905.422-1-markovicbudimir@gmail.com
835086
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
835086
835086
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
835086
835086
commit d5ca9824c050deefa376decdba70e7f992397a58
835086
Author: Davide Caratti <dcaratti@redhat.com>
835086
Date:   Tue Nov 21 18:08:37 2023 +0100
835086
835086
    net/sched: sch_hfsc: upgrade 'rt' to 'sc' when it becomes a inner curve
835086
835086
    JIRA: https://issues.redhat.com/browse/RHEL-16458
835086
    CVE: CVE-2023-4623
835086
    Upstream Status: net.git commit a13b67c9a015c4e21601ef9aa4ec9c5d972df1b4
835086
835086
    commit a13b67c9a015c4e21601ef9aa4ec9c5d972df1b4
835086
    Author: Pedro Tammela <pctammela@mojatatu.com>
835086
    Date:   Tue Oct 17 11:36:02 2023 -0300
835086
835086
        net/sched: sch_hfsc: upgrade 'rt' to 'sc' when it becomes a inner curve
835086
835086
        Christian Theune says:
835086
           I upgraded from 6.1.38 to 6.1.55 this morning and it broke my traffic shaping script,
835086
           leaving me with a non-functional uplink on a remote router.
835086
835086
        A 'rt' curve cannot be used as a inner curve (parent class), but we were
835086
        allowing such configurations since the qdisc was introduced. Such
835086
        configurations would trigger a UAF as Budimir explains:
835086
           The parent will have vttree_insert() called on it in init_vf(),
835086
           but will not have vttree_remove() called on it in update_vf()
835086
           because it does not have the HFSC_FSC flag set.
835086
835086
        The qdisc always assumes that inner classes have the HFSC_FSC flag set.
835086
        This is by design as it doesn't make sense 'qdisc wise' for an 'rt'
835086
        curve to be an inner curve.
835086
835086
        Budimir's original patch disallows users to add classes with a 'rt'
835086
        parent, but this is too strict as it breaks users that have been using
835086
        'rt' as a inner class. Another approach, taken by this patch, is to
835086
        upgrade the inner 'rt' into a 'sc', warning the user in the process.
835086
        It avoids the UAF reported by Budimir while also being more permissive
835086
        to bad scripts/users/code using 'rt' as a inner class.
835086
835086
        Users checking the `tc class ls [...]` or `tc class get [...]` dumps would
835086
        observe the curve change and are potentially breaking with this change.
835086
835086
        v1->v2: https://lore.kernel.org/all/20231013151057.2611860-1-pctammela@mojatatu.com/
835086
        - Correct 'Fixes' tag and merge with revert (Jakub)
835086
835086
        Cc: Christian Theune <ct@flyingcircus.io>
835086
        Cc: Budimir Markovic <markovicbudimir@gmail.com>
835086
        Fixes: b3d26c5702c7 ("net/sched: sch_hfsc: Ensure inner classes have fsc curve")
835086
        Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
835086
        Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
835086
        Link: https://lore.kernel.org/r/20231017143602.3191556-1-pctammela@mojatatu.com
835086
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
835086
835086
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
835086
835086
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
835086
---
835086
 net/sched/sch_hfsc.c | 14 ++++++++++++++
835086
 1 file changed, 14 insertions(+)
835086
835086
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
835086
index fb14b551f65d..63e768f5ce21 100644
835086
--- a/net/sched/sch_hfsc.c
835086
+++ b/net/sched/sch_hfsc.c
835086
@@ -913,6 +913,14 @@ hfsc_change_usc(struct hfsc_class *cl, struct tc_service_curve *usc,
835086
 	cl->cl_flags |= HFSC_USC;
835086
 }
835086
 
835086
+static void
835086
+hfsc_upgrade_rt(struct hfsc_class *cl)
835086
+{
835086
+	cl->cl_fsc = cl->cl_rsc;
835086
+	rtsc_init(&cl->cl_virtual, &cl->cl_fsc, cl->cl_vt, cl->cl_total);
835086
+	cl->cl_flags |= HFSC_FSC;
835086
+}
835086
+
835086
 static const struct nla_policy hfsc_policy[TCA_HFSC_MAX + 1] = {
835086
 	[TCA_HFSC_RSC]	= { .len = sizeof(struct tc_service_curve) },
835086
 	[TCA_HFSC_FSC]	= { .len = sizeof(struct tc_service_curve) },
835086
@@ -1072,6 +1080,12 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
835086
 	cl->cf_tree = RB_ROOT;
835086
 
835086
 	sch_tree_lock(sch);
835086
+	/* Check if the inner class is a misconfigured 'rt' */
835086
+	if (!(parent->cl_flags & HFSC_FSC) && parent != &q->root) {
835086
+		NL_SET_ERR_MSG(extack,
835086
+			       "Forced curve change on parent 'rt' to 'sc'");
835086
+		hfsc_upgrade_rt(parent);
835086
+	}
835086
 	qdisc_class_hash_insert(&q->clhash, &cl->cl_common);
835086
 	list_add_tail(&cl->siblings, &parent->children);
835086
 	if (parent->level == 0)
835086
-- 
835086
2.44.0
835086
835086