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