Blame SOURCES/CVE-2023-3776.patch

d28903
From 8a3e286f2ff1f83ffd645cbad1cb49f80ab2ab00 Mon Sep 17 00:00:00 2001
d28903
From: Ryan Sullivan <rysulliv@redhat.com>
d28903
Date: Tue, 17 Oct 2023 13:28:46 -0400
d28903
Subject: [KPATCH CVE-2023-3776] kpatch fixes for CVE-2023-3776
d28903
d28903
Kernels:
d28903
3.10.0-1160.90.1.el7
d28903
3.10.0-1160.92.1.el7
d28903
3.10.0-1160.95.1.el7
d28903
3.10.0-1160.99.1.el7
d28903
3.10.0-1160.102.1.el7
d28903
d28903
d28903
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/61
d28903
Approved-by: Joe Lawrence (@joe.lawrence)
d28903
Approved-by: Yannick Cote (@ycote1)
d28903
Changes since last build:
d28903
arches: x86_64 ppc64le
d28903
cls_fw.o: changed function: fw_change
d28903
cls_fw.o: changed function: fw_set_parms
d28903
cls_route.o: changed function: route4_change
d28903
cls_u32.o: changed function: u32_change
d28903
sch_qfq.o: changed function: qfq_enqueue
d28903
---------------------------
d28903
d28903
Modifications: none
d28903
d28903
commit 726e9f3d88c729cdae09768c94e588deebdb9d52
d28903
Author: Marcelo Tosatti <mtosatti@redhat.com>
d28903
Date:   Mon Jan 23 17:17:17 2023 -0300
d28903
d28903
    KVM: x86: rename argument to kvm_set_tsc_khz
d28903
d28903
    commit 4941b8cb3746f09bb102f7a5d64d878e96a0c6cd
d28903
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152838
d28903
    JIRA: https://issues.redhat.com/browse/RHELPLAN-141963
d28903
    Testing: Tested by QE
d28903
d28903
    This refers to the desired (scaled) frequency, which is called
d28903
    user_tsc_khz in the rest of the file.
d28903
d28903
    Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
d28903
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
d28903
    Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
d28903
d28903
commit 866faa0e99083ee93d04d3c37065cf8dbfc51a34
d28903
Author: Marcelo Tosatti <mtosatti@redhat.com>
d28903
Date:   Mon Jan 23 17:24:19 2023 -0300
d28903
d28903
    KVM: x86: rewrite handling of scaled TSC for kvmclock
d28903
d28903
    commit 78db6a5037965429c04d708281f35a6e5562d31b
d28903
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152838
d28903
    Testing: Tested by QE
d28903
    JIRA: https://issues.redhat.com/browse/RHELPLAN-141963
d28903
d28903
    This is the same as before:
d28903
d28903
        kvm_scale_tsc(tgt_tsc_khz)
d28903
            = tgt_tsc_khz * ratio
d28903
            = tgt_tsc_khz * user_tsc_khz / tsc_khz   (see set_tsc_khz)
d28903
            = user_tsc_khz                           (see kvm_guest_time_update)
d28903
            = vcpu->arch.virtual_tsc_khz             (see kvm_set_tsc_khz)
d28903
d28903
    However, computing it through kvm_scale_tsc will make it possible
d28903
    to include the NTP correction in tgt_tsc_khz.
d28903
d28903
    Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
d28903
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
d28903
    Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
d28903
d28903
commit bde6eebb5708ecd38db0023e657d38058e0d962f
d28903
Author: Marcelo Tosatti <mtosatti@redhat.com>
d28903
Date:   Wed Jan 25 16:07:18 2023 -0300
d28903
d28903
    KVM: x86: add bit to indicate correct tsc_shift
d28903
d28903
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152838
d28903
    Testing: Tested by QE
d28903
    Upstream Status: RHEL7 only
d28903
    JIRA: https://issues.redhat.com/browse/RHELPLAN-141963
d28903
d28903
    This changeset is unique to RHEL-7 since it was decided
d28903
    it is not necessary upstream:
d28903
d28903
    "I don't think it's justifiable to further complicate the userspace API for a
d28903
    bug that's been fixed six years ago.  I'd be very surprised if any combination
d28903
    of modern upstream {QEMU,kernel} is going to do a successful migration from
d28903
    such an old {QEMU,kernel}.  RHEL/CentOS are able to do so because *specific
d28903
    pairs* have been tested, but as far as upstream is concerned this adds
d28903
    complexity that absolutely no one will use."
d28903
d28903
    Before commit 78db6a5037965429c04d708281f35a6e5562d31b,
d28903
    kvm_guest_time_update() would use vcpu->virtual_tsc_khz to calculate
d28903
    tsc_shift value in the vcpus pvclock structure written to guest memory.
d28903
d28903
    For those kernels, if vcpu->virtual_tsc_khz != tsc_khz (which can be the
d28903
    case when guest state is restored via migration, or if tsc-khz option is
d28903
    passed to QEMU), and TSC scaling is not enabled (which happens if the
d28903
    difference between the frequency requested via KVM_SET_TSC_KHZ and the
d28903
    host TSC KHZ is smaller than 250ppm), then there can be a difference
d28903
    between what KVM_GET_CLOCK would return and what the guest reads as
d28903
    kvmclock value.
d28903
d28903
    When KVM_SET_CLOCK'ing what is read with KVM_GET_CLOCK, the
d28903
    guest can observe a forward or backwards time jump.
d28903
d28903
    Advertise to userspace that current kernel contains
d28903
    this fix, so QEMU can workaround the problem by reading
d28903
    pvclock via guest memory directly otherwise.
d28903
d28903
    Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
d28903
d28903
commit 373ed8339c956ce1d9049737bab779f143fc1267
d28903
Author: Davide Caratti <dcaratti@redhat.com>
d28903
Date:   Tue Aug 8 11:57:51 2023 +0200
d28903
d28903
    net/sched: cls_fw: Fix improper refcount update leads to use-after-free
d28903
d28903
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2225639
d28903
    CVE: CVE-2023-3776
d28903
    Upstream Status: net.git commit 0323bce598ee
d28903
    Conflicts:
d28903
     - net/sched/cls_fw.c: context mismatch because of missing backport
d28903
       of upstream commit a51486266c3b ("net: sched: remove NET_CLS_IND
d28903
       config option")
d28903
d28903
    commit 0323bce598eea038714f941ce2b22541c46d488f
d28903
    Author: M A Ramdhan <ramdhan@starlabs.sg>
d28903
    Date:   Wed Jul 5 12:15:30 2023 -0400
d28903
d28903
        net/sched: cls_fw: Fix improper refcount update leads to use-after-free
d28903
d28903
        In the event of a failure in tcf_change_indev(), fw_set_parms() will
d28903
        immediately return an error after incrementing or decrementing
d28903
        reference counter in tcf_bind_filter().  If attacker can control
d28903
        reference counter to zero and make reference freed, leading to
d28903
        use after free.
d28903
d28903
        In order to prevent this, move the point of possible failure above the
d28903
        point where the TC_FW_CLASSID is handled.
d28903
d28903
        Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
d28903
        Reported-by: M A Ramdhan <ramdhan@starlabs.sg>
d28903
        Signed-off-by: M A Ramdhan <ramdhan@starlabs.sg>
d28903
        Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
d28903
        Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
d28903
        Message-ID: <20230705161530.52003-1-ramdhan@starlabs.sg>
d28903
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
d28903
d28903
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
d28903
d28903
Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
d28903
---
d28903
 net/sched/cls_fw.c | 10 +++++-----
d28903
 1 file changed, 5 insertions(+), 5 deletions(-)
d28903
d28903
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
d28903
index e05043266620..3427222f8e60 100644
d28903
--- a/net/sched/cls_fw.c
d28903
+++ b/net/sched/cls_fw.c
d28903
@@ -218,11 +218,6 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp,
d28903
 	if (err < 0)
d28903
 		return err;
d28903
 
d28903
-	if (tb[TCA_FW_CLASSID]) {
d28903
-		f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]);
d28903
-		tcf_bind_filter(tp, &f->res, base);
d28903
-	}
d28903
-
d28903
 #ifdef CONFIG_NET_CLS_IND
d28903
 	if (tb[TCA_FW_INDEV]) {
d28903
 		int ret;
d28903
@@ -241,6 +236,11 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp,
d28903
 	} else if (head->mask != 0xFFFFFFFF)
d28903
 		return err;
d28903
 
d28903
+	if (tb[TCA_FW_CLASSID]) {
d28903
+		f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]);
d28903
+		tcf_bind_filter(tp, &f->res, base);
d28903
+	}
d28903
+
d28903
 	return 0;
d28903
 }
d28903
 
d28903
-- 
d28903
2.41.0
d28903
d28903