Blame SOURCES/CVE-2023-4128.patch

b5132d
From d755c1f10a580e972fafb7bebf24378b5b830b98 Mon Sep 17 00:00:00 2001
b5132d
From: Ryan Sullivan <rysulliv@redhat.com>
b5132d
Date: Tue, 7 Nov 2023 15:04:48 -0500
b5132d
Subject: [KPATCH CVE-2023-4128] kpatch fixes for CVE-2023-4128
b5132d
b5132d
Kernels:
b5132d
3.10.0-1160.90.1.el7
b5132d
3.10.0-1160.92.1.el7
b5132d
3.10.0-1160.95.1.el7
b5132d
3.10.0-1160.99.1.el7
b5132d
3.10.0-1160.102.1.el7
b5132d
b5132d
b5132d
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/62
b5132d
Approved-by: Joe Lawrence (@joe.lawrence)
b5132d
Approved-by: Yannick Cote (@ycote1)
b5132d
Changes since last build:
b5132d
arches: x86_64 ppc64le
b5132d
cls_fw.o: changed function: fw_change
b5132d
cls_fw.o: changed function: fw_set_parms
b5132d
cls_route.o: changed function: route4_change
b5132d
cls_u32.o: changed function: u32_change
b5132d
sch_qfq.o: changed function: qfq_enqueue
b5132d
---------------------------
b5132d
b5132d
Modifications: none
b5132d
b5132d
commit 726e9f3d88c729cdae09768c94e588deebdb9d52
b5132d
Author: Marcelo Tosatti <mtosatti@redhat.com>
b5132d
Date:   Mon Jan 23 17:17:17 2023 -0300
b5132d
b5132d
    KVM: x86: rename argument to kvm_set_tsc_khz
b5132d
b5132d
    commit 4941b8cb3746f09bb102f7a5d64d878e96a0c6cd
b5132d
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152838
b5132d
    JIRA: https://issues.redhat.com/browse/RHELPLAN-141963
b5132d
    Testing: Tested by QE
b5132d
b5132d
    This refers to the desired (scaled) frequency, which is called
b5132d
    user_tsc_khz in the rest of the file.
b5132d
b5132d
    Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
b5132d
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
b5132d
    Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
b5132d
b5132d
commit 866faa0e99083ee93d04d3c37065cf8dbfc51a34
b5132d
Author: Marcelo Tosatti <mtosatti@redhat.com>
b5132d
Date:   Mon Jan 23 17:24:19 2023 -0300
b5132d
b5132d
    KVM: x86: rewrite handling of scaled TSC for kvmclock
b5132d
b5132d
    commit 78db6a5037965429c04d708281f35a6e5562d31b
b5132d
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152838
b5132d
    Testing: Tested by QE
b5132d
    JIRA: https://issues.redhat.com/browse/RHELPLAN-141963
b5132d
b5132d
    This is the same as before:
b5132d
b5132d
        kvm_scale_tsc(tgt_tsc_khz)
b5132d
            = tgt_tsc_khz * ratio
b5132d
            = tgt_tsc_khz * user_tsc_khz / tsc_khz   (see set_tsc_khz)
b5132d
            = user_tsc_khz                           (see kvm_guest_time_update)
b5132d
            = vcpu->arch.virtual_tsc_khz             (see kvm_set_tsc_khz)
b5132d
b5132d
    However, computing it through kvm_scale_tsc will make it possible
b5132d
    to include the NTP correction in tgt_tsc_khz.
b5132d
b5132d
    Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
b5132d
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
b5132d
    Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
b5132d
b5132d
commit bde6eebb5708ecd38db0023e657d38058e0d962f
b5132d
Author: Marcelo Tosatti <mtosatti@redhat.com>
b5132d
Date:   Wed Jan 25 16:07:18 2023 -0300
b5132d
b5132d
    KVM: x86: add bit to indicate correct tsc_shift
b5132d
b5132d
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152838
b5132d
    Testing: Tested by QE
b5132d
    Upstream Status: RHEL7 only
b5132d
    JIRA: https://issues.redhat.com/browse/RHELPLAN-141963
b5132d
b5132d
    This changeset is unique to RHEL-7 since it was decided
b5132d
    it is not necessary upstream:
b5132d
b5132d
    "I don't think it's justifiable to further complicate the userspace API for a
b5132d
    bug that's been fixed six years ago.  I'd be very surprised if any combination
b5132d
    of modern upstream {QEMU,kernel} is going to do a successful migration from
b5132d
    such an old {QEMU,kernel}.  RHEL/CentOS are able to do so because *specific
b5132d
    pairs* have been tested, but as far as upstream is concerned this adds
b5132d
    complexity that absolutely no one will use."
b5132d
b5132d
    Before commit 78db6a5037965429c04d708281f35a6e5562d31b,
b5132d
    kvm_guest_time_update() would use vcpu->virtual_tsc_khz to calculate
b5132d
    tsc_shift value in the vcpus pvclock structure written to guest memory.
b5132d
b5132d
    For those kernels, if vcpu->virtual_tsc_khz != tsc_khz (which can be the
b5132d
    case when guest state is restored via migration, or if tsc-khz option is
b5132d
    passed to QEMU), and TSC scaling is not enabled (which happens if the
b5132d
    difference between the frequency requested via KVM_SET_TSC_KHZ and the
b5132d
    host TSC KHZ is smaller than 250ppm), then there can be a difference
b5132d
    between what KVM_GET_CLOCK would return and what the guest reads as
b5132d
    kvmclock value.
b5132d
b5132d
    When KVM_SET_CLOCK'ing what is read with KVM_GET_CLOCK, the
b5132d
    guest can observe a forward or backwards time jump.
b5132d
b5132d
    Advertise to userspace that current kernel contains
b5132d
    this fix, so QEMU can workaround the problem by reading
b5132d
    pvclock via guest memory directly otherwise.
b5132d
b5132d
    Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
b5132d
b5132d
commit 55a81001d2c4927795b36be55f54675f325c9ef2
b5132d
Author: Davide Caratti <dcaratti@redhat.com>
b5132d
Date:   Wed Aug 9 15:22:14 2023 +0200
b5132d
b5132d
    net/sched: cls_route: No longer copy tcf_result on update to avoid use-after-free
b5132d
b5132d
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2228703
b5132d
    CVE: CVE-2023-4128
b5132d
    Upstream Status: net.git commit b80b829e9e2c
b5132d
b5132d
    commit b80b829e9e2c1b3f7aae34855e04d8f6ecaf13c8
b5132d
    Author: valis <sec@valis.email>
b5132d
    Date:   Sat Jul 29 08:32:02 2023 -0400
b5132d
b5132d
        net/sched: cls_route: No longer copy tcf_result on update to avoid use-after-free
b5132d
b5132d
        When route4_change() is called on an existing filter, the whole
b5132d
        tcf_result struct is always copied into the new instance of the filter.
b5132d
b5132d
        This causes a problem when updating a filter bound to a class,
b5132d
        as tcf_unbind_filter() is always called on the old instance in the
b5132d
        success path, decreasing filter_cnt of the still referenced class
b5132d
        and allowing it to be deleted, leading to a use-after-free.
b5132d
b5132d
        Fix this by no longer copying the tcf_result struct from the old filter.
b5132d
b5132d
        Fixes: 1109c00547fc ("net: sched: RCU cls_route")
b5132d
        Reported-by: valis <sec@valis.email>
b5132d
        Reported-by: Bing-Jhong Billy Jheng <billy@starlabs.sg>
b5132d
        Signed-off-by: valis <sec@valis.email>
b5132d
        Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
b5132d
        Reviewed-by: Victor Nogueira <victor@mojatatu.com>
b5132d
        Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
b5132d
        Reviewed-by: M A Ramdhan <ramdhan@starlabs.sg>
b5132d
        Link: https://lore.kernel.org/r/20230729123202.72406-4-jhs@mojatatu.com
b5132d
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
b5132d
b5132d
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
b5132d
b5132d
commit 820985c32b9616c7e793206ef8f8aff7c5ccfc8b
b5132d
Author: Davide Caratti <dcaratti@redhat.com>
b5132d
Date:   Wed Aug 9 15:22:15 2023 +0200
b5132d
b5132d
    net/sched: cls_fw: No longer copy tcf_result on update to avoid use-after-free
b5132d
b5132d
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2228703
b5132d
    CVE: CVE-2023-4128
b5132d
    Upstream Status: net.git commit 76e42ae83199
b5132d
    Conflicts:
b5132d
     - net/sched/cls_fw.c: context mismatch because of missing upstream commit
b5132d
       a51486266c3b ("net: sched: remove NET_CLS_IND config option")
b5132d
b5132d
    commit 76e42ae831991c828cffa8c37736ebfb831ad5ec
b5132d
    Author: valis <sec@valis.email>
b5132d
    Date:   Sat Jul 29 08:32:01 2023 -0400
b5132d
b5132d
        net/sched: cls_fw: No longer copy tcf_result on update to avoid use-after-free
b5132d
b5132d
        When fw_change() is called on an existing filter, the whole
b5132d
        tcf_result struct is always copied into the new instance of the filter.
b5132d
b5132d
        This causes a problem when updating a filter bound to a class,
b5132d
        as tcf_unbind_filter() is always called on the old instance in the
b5132d
        success path, decreasing filter_cnt of the still referenced class
b5132d
        and allowing it to be deleted, leading to a use-after-free.
b5132d
b5132d
        Fix this by no longer copying the tcf_result struct from the old filter.
b5132d
b5132d
        Fixes: e35a8ee5993b ("net: sched: fw use RCU")
b5132d
        Reported-by: valis <sec@valis.email>
b5132d
        Reported-by: Bing-Jhong Billy Jheng <billy@starlabs.sg>
b5132d
        Signed-off-by: valis <sec@valis.email>
b5132d
        Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
b5132d
        Reviewed-by: Victor Nogueira <victor@mojatatu.com>
b5132d
        Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
b5132d
        Reviewed-by: M A Ramdhan <ramdhan@starlabs.sg>
b5132d
        Link: https://lore.kernel.org/r/20230729123202.72406-3-jhs@mojatatu.com
b5132d
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
b5132d
b5132d
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
b5132d
b5132d
commit 86b6be644c207dd3f4b3ecf4975a771608f0cece
b5132d
Author: Davide Caratti <dcaratti@redhat.com>
b5132d
Date:   Wed Aug 9 15:23:37 2023 +0200
b5132d
b5132d
    net/sched: cls_u32: No longer copy tcf_result on update to avoid use-after-free
b5132d
b5132d
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2228703
b5132d
    CVE: CVE-2023-4128
b5132d
    Upstream Status: net.git commit 3044b16e7c6f
b5132d
b5132d
    commit 3044b16e7c6fe5d24b1cdbcf1bd0a9d92d1ebd81
b5132d
    Author: valis <sec@valis.email>
b5132d
    Date:   Sat Jul 29 08:32:00 2023 -0400
b5132d
b5132d
        net/sched: cls_u32: No longer copy tcf_result on update to avoid use-after-free
b5132d
b5132d
        When u32_change() is called on an existing filter, the whole
b5132d
        tcf_result struct is always copied into the new instance of the filter.
b5132d
b5132d
        This causes a problem when updating a filter bound to a class,
b5132d
        as tcf_unbind_filter() is always called on the old instance in the
b5132d
        success path, decreasing filter_cnt of the still referenced class
b5132d
        and allowing it to be deleted, leading to a use-after-free.
b5132d
b5132d
        Fix this by no longer copying the tcf_result struct from the old filter.
b5132d
b5132d
        Fixes: de5df63228fc ("net: sched: cls_u32 changes to knode must appear atomic to readers")
b5132d
        Reported-by: valis <sec@valis.email>
b5132d
        Reported-by: M A Ramdhan <ramdhan@starlabs.sg>
b5132d
        Signed-off-by: valis <sec@valis.email>
b5132d
        Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
b5132d
        Reviewed-by: Victor Nogueira <victor@mojatatu.com>
b5132d
        Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
b5132d
        Reviewed-by: M A Ramdhan <ramdhan@starlabs.sg>
b5132d
        Link: https://lore.kernel.org/r/20230729123202.72406-2-jhs@mojatatu.com
b5132d
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
b5132d
b5132d
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
b5132d
b5132d
Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
b5132d
---
b5132d
 net/sched/cls_fw.c    | 1 -
b5132d
 net/sched/cls_route.c | 1 -
b5132d
 net/sched/cls_u32.c   | 1 -
b5132d
 3 files changed, 3 deletions(-)
b5132d
b5132d
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
b5132d
index e05043266620..57563d1bf7a0 100644
b5132d
--- a/net/sched/cls_fw.c
b5132d
+++ b/net/sched/cls_fw.c
b5132d
@@ -274,7 +274,6 @@ static int fw_change(struct net *net, struct sk_buff *in_skb,
b5132d
 			return -ENOBUFS;
b5132d
 
b5132d
 		fnew->id = f->id;
b5132d
-		fnew->res = f->res;
b5132d
 #ifdef CONFIG_NET_CLS_IND
b5132d
 		fnew->ifindex = f->ifindex;
b5132d
 #endif /* CONFIG_NET_CLS_IND */
b5132d
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
b5132d
index d97c5bcdfa43..0bd48bd0bf9b 100644
b5132d
--- a/net/sched/cls_route.c
b5132d
+++ b/net/sched/cls_route.c
b5132d
@@ -501,7 +501,6 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
b5132d
 	if (fold) {
b5132d
 		f->id = fold->id;
b5132d
 		f->iif = fold->iif;
b5132d
-		f->res = fold->res;
b5132d
 		f->handle = fold->handle;
b5132d
 
b5132d
 		f->tp = fold->tp;
b5132d
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
b5132d
index cc9398e10451..73e97f73447a 100644
b5132d
--- a/net/sched/cls_u32.c
b5132d
+++ b/net/sched/cls_u32.c
b5132d
@@ -864,7 +864,6 @@ static struct tc_u_knode *u32_init_knode(struct tcf_proto *tp,
b5132d
 	new->ifindex = n->ifindex;
b5132d
 #endif
b5132d
 	new->fshift = n->fshift;
b5132d
-	new->res = n->res;
b5132d
 	new->flags = n->flags;
b5132d
 	RCU_INIT_POINTER(new->ht_down, n->ht_down);
b5132d
 
b5132d
-- 
b5132d
2.41.0
b5132d
b5132d