Blame SOURCES/CVE-2023-4623.patch

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