|
|
da2c8e |
From 9ab861c9a630d07a8ac0240f81dd0067b6c57963 Mon Sep 17 00:00:00 2001
|
|
|
da2c8e |
From: Joel Savitz <jsavitz@redhat.com>
|
|
|
da2c8e |
Date: Mon, 20 Sep 2021 13:49:09 -0400
|
|
|
da2c8e |
Subject: [KPATCH CVE-2021-37576] KVM: PPC: kpatch fixes for CVE-2021-37576
|
|
|
da2c8e |
|
|
|
da2c8e |
Kernels:
|
|
|
da2c8e |
3.10.0-1160.el7
|
|
|
da2c8e |
3.10.0-1160.2.1.el7
|
|
|
da2c8e |
3.10.0-1160.2.2.el7
|
|
|
da2c8e |
3.10.0-1160.6.1.el7
|
|
|
da2c8e |
3.10.0-1160.11.1.el7
|
|
|
da2c8e |
3.10.0-1160.15.2.el7
|
|
|
da2c8e |
3.10.0-1160.21.1.el7
|
|
|
da2c8e |
3.10.0-1160.24.1.el7
|
|
|
da2c8e |
3.10.0-1160.25.1.el7
|
|
|
da2c8e |
3.10.0-1160.31.1.el7
|
|
|
da2c8e |
3.10.0-1160.36.2.el7
|
|
|
da2c8e |
3.10.0-1160.41.1.el7
|
|
|
da2c8e |
3.10.0-1160.42.2.el7
|
|
|
da2c8e |
|
|
|
da2c8e |
Changes since last build:
|
|
|
da2c8e |
arches: ppc64le
|
|
|
da2c8e |
book3s_rtas.o: changed function: kvmppc_rtas_hcall
|
|
|
da2c8e |
---------------------------
|
|
|
da2c8e |
|
|
|
da2c8e |
Kernels:
|
|
|
da2c8e |
3.10.0-1160.2.1.el7
|
|
|
da2c8e |
3.10.0-1160.2.2.el7
|
|
|
da2c8e |
3.10.0-1160.6.1.el7
|
|
|
da2c8e |
3.10.0-1160.11.1.el7
|
|
|
da2c8e |
3.10.0-1160.15.2.el7
|
|
|
da2c8e |
3.10.0-1160.21.1.el7
|
|
|
da2c8e |
3.10.0-1160.24.1.el7
|
|
|
da2c8e |
3.10.0-1160.25.1.el7
|
|
|
da2c8e |
3.10.0-1160.31.1.el7
|
|
|
da2c8e |
3.10.0-1160.36.2.el7
|
|
|
da2c8e |
3.10.0-1160.41.1.el7
|
|
|
da2c8e |
3.10.0-1160.42.2.el7
|
|
|
da2c8e |
|
|
|
da2c8e |
Modifications: None
|
|
|
da2c8e |
Kpatch-MR: https://gitlab.com/kpatch-dev/rhel-7/-/merge_requests/8
|
|
|
da2c8e |
Approved-by: Artem Savkov (@artem.savkov)
|
|
|
da2c8e |
Approved-by: Joe Lawrence (@joe.lawrence)
|
|
|
da2c8e |
Approved-by: Yannick Cote (@ycote1)
|
|
|
da2c8e |
|
|
|
da2c8e |
Z-MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-7/-/merge_requests/274
|
|
|
da2c8e |
|
|
|
da2c8e |
No reproducer available, tested via manual install and:
|
|
|
da2c8e |
KT0 test PASS (ppc64le only): https://beaker.engineering.redhat.com/jobs/5809981
|
|
|
da2c8e |
|
|
|
da2c8e |
for scratch build: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=39840849
|
|
|
da2c8e |
|
|
|
da2c8e |
commit e1b729d6d332cc22fe641edc723324222096bf29
|
|
|
da2c8e |
Author: Jon Maloy <jmaloy@redhat.com>
|
|
|
da2c8e |
Date: Thu Aug 12 19:22:51 2021 -0400
|
|
|
da2c8e |
|
|
|
da2c8e |
KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow
|
|
|
da2c8e |
|
|
|
da2c8e |
Bugzilla: https://bugzilla.redhat.com/1988218
|
|
|
da2c8e |
Upstream Status: Merged
|
|
|
da2c8e |
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=39246436
|
|
|
da2c8e |
CVE: CVE-2021-37576
|
|
|
da2c8e |
|
|
|
da2c8e |
commit f62f3c20647ebd5fb6ecb8f0b477b9281c44c10a
|
|
|
da2c8e |
Author: Nicholas Piggin <npiggin@gmail.com>
|
|
|
da2c8e |
Date: Tue Jul 20 20:43:09 2021 +1000
|
|
|
da2c8e |
|
|
|
da2c8e |
KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow
|
|
|
da2c8e |
|
|
|
da2c8e |
The kvmppc_rtas_hcall() sets the host rtas_args.rets pointer based on
|
|
|
da2c8e |
the rtas_args.nargs that was provided by the guest. That guest nargs
|
|
|
da2c8e |
value is not range checked, so the guest can cause the host rets pointer
|
|
|
da2c8e |
to be pointed outside the args array. The individual rtas function
|
|
|
da2c8e |
handlers check the nargs and nrets values to ensure they are correct,
|
|
|
da2c8e |
but if they are not, the handlers store a -3 (0xfffffffd) failure
|
|
|
da2c8e |
indication in rets[0] which corrupts host memory.
|
|
|
da2c8e |
|
|
|
da2c8e |
Fix this by testing up front whether the guest supplied nargs and nret
|
|
|
da2c8e |
would exceed the array size, and fail the hcall directly without storing
|
|
|
da2c8e |
a failure indication to rets[0].
|
|
|
da2c8e |
|
|
|
da2c8e |
Also expand on a comment about why we kill the guest and try not to
|
|
|
da2c8e |
return errors directly if we have a valid rets[0] pointer.
|
|
|
da2c8e |
|
|
|
da2c8e |
Fixes: 8e591cb72047 ("KVM: PPC: Book3S: Add infrastructure to implement kernel-side RTAS calls")
|
|
|
da2c8e |
Cc: stable@vger.kernel.org # v3.10+
|
|
|
da2c8e |
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
|
da2c8e |
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
|
|
|
da2c8e |
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
|
|
|
da2c8e |
|
|
|
da2c8e |
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
da2c8e |
|
|
|
da2c8e |
Signed-off-by: Joel Savitz <jsavitz@redhat.com>
|
|
|
da2c8e |
---
|
|
|
da2c8e |
arch/powerpc/kvm/book3s_rtas.c | 25 ++++++++++++++++++++++---
|
|
|
da2c8e |
1 file changed, 22 insertions(+), 3 deletions(-)
|
|
|
da2c8e |
|
|
|
da2c8e |
diff --git a/arch/powerpc/kvm/book3s_rtas.c b/arch/powerpc/kvm/book3s_rtas.c
|
|
|
da2c8e |
index ef27fbd5d9c5..d896c6854abc 100644
|
|
|
da2c8e |
--- a/arch/powerpc/kvm/book3s_rtas.c
|
|
|
da2c8e |
+++ b/arch/powerpc/kvm/book3s_rtas.c
|
|
|
da2c8e |
@@ -230,6 +230,17 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu)
|
|
|
da2c8e |
* value so we can restore it on the way out.
|
|
|
da2c8e |
*/
|
|
|
da2c8e |
orig_rets = args.rets;
|
|
|
da2c8e |
+ if (be32_to_cpu(args.nargs) >= ARRAY_SIZE(args.args)) {
|
|
|
da2c8e |
+ /*
|
|
|
da2c8e |
+ * Don't overflow our args array: ensure there is room for
|
|
|
da2c8e |
+ * at least rets[0] (even if the call specifies 0 nret).
|
|
|
da2c8e |
+ *
|
|
|
da2c8e |
+ * Each handler must then check for the correct nargs and nret
|
|
|
da2c8e |
+ * values, but they may always return failure in rets[0].
|
|
|
da2c8e |
+ */
|
|
|
da2c8e |
+ rc = -EINVAL;
|
|
|
da2c8e |
+ goto fail;
|
|
|
da2c8e |
+ }
|
|
|
da2c8e |
args.rets = &args.args[be32_to_cpu(args.nargs)];
|
|
|
da2c8e |
|
|
|
da2c8e |
mutex_lock(&vcpu->kvm->lock);
|
|
|
da2c8e |
@@ -257,9 +268,17 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu)
|
|
|
da2c8e |
fail:
|
|
|
da2c8e |
/*
|
|
|
da2c8e |
* We only get here if the guest has called RTAS with a bogus
|
|
|
da2c8e |
- * args pointer. That means we can't get to the args, and so we
|
|
|
da2c8e |
- * can't fail the RTAS call. So fail right out to userspace,
|
|
|
da2c8e |
- * which should kill the guest.
|
|
|
da2c8e |
+ * args pointer or nargs/nret values that would overflow the
|
|
|
da2c8e |
+ * array. That means we can't get to the args, and so we can't
|
|
|
da2c8e |
+ * fail the RTAS call. So fail right out to userspace, which
|
|
|
da2c8e |
+ * should kill the guest.
|
|
|
da2c8e |
+ *
|
|
|
da2c8e |
+ * SLOF should actually pass the hcall return value from the
|
|
|
da2c8e |
+ * rtas handler call in r3, so enter_rtas could be modified to
|
|
|
da2c8e |
+ * return a failure indication in r3 and we could return such
|
|
|
da2c8e |
+ * errors to the guest rather than failing to host userspace.
|
|
|
da2c8e |
+ * However old guests that don't test for failure could then
|
|
|
da2c8e |
+ * continue silently after errors, so for now we won't do this.
|
|
|
da2c8e |
*/
|
|
|
da2c8e |
return rc;
|
|
|
da2c8e |
}
|
|
|
da2c8e |
--
|
|
|
da2c8e |
2.26.3
|
|
|
da2c8e |
|
|
|
da2c8e |
|