Blame SOURCES/CVE-2023-4623.patch

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