|
|
8215de |
From 742fee241938f6089d67c4e779ba0d608a9d88e3 Mon Sep 17 00:00:00 2001
|
|
|
8215de |
From: Joe Lawrence <joe.lawrence@redhat.com>
|
|
|
8215de |
Date: Mon, 30 Aug 2021 16:54:36 -0400
|
|
|
8215de |
Subject: [KPATCH CVE-2021-37576] powerpc: kpatch fixes for CVE-2021-37576
|
|
|
8215de |
|
|
|
8215de |
Kernels:
|
|
|
8215de |
4.18.0-305.el8
|
|
|
8215de |
4.18.0-305.3.1.el8_4
|
|
|
8215de |
4.18.0-305.7.1.el8_4
|
|
|
8215de |
4.18.0-305.10.2.el8_4
|
|
|
8215de |
4.18.0-305.12.1.el8_4
|
|
|
8215de |
|
|
|
8215de |
arches: ppc64le
|
|
|
8215de |
Changes since last build:
|
|
|
8215de |
[ppc64le]:
|
|
|
8215de |
book3s_rtas.o: changed function: kvmppc_rtas_hcall
|
|
|
8215de |
|
|
|
8215de |
---------------------------
|
|
|
8215de |
|
|
|
8215de |
Kernels:
|
|
|
8215de |
4.18.0-305.el8
|
|
|
8215de |
4.18.0-305.3.1.el8_4
|
|
|
8215de |
4.18.0-305.7.1.el8_4
|
|
|
8215de |
4.18.0-305.10.2.el8_4
|
|
|
8215de |
4.18.0-305.12.1.el8_4
|
|
|
8215de |
|
|
|
8215de |
Modifications: none
|
|
|
8215de |
Approved-by: Yannick Cote (@ycote1)
|
|
|
8215de |
Approved-by: Artem Savkov (@artem.savkov)
|
|
|
8215de |
KPATCH-MR: https://gitlab.com/kpatch-dev/rhel-8/-/merge_requests/2
|
|
|
8215de |
|
|
|
8215de |
KT0 test PASS: https://beaker.engineering.redhat.com/jobs/5756102
|
|
|
8215de |
for kpatch-patch-4_18_0-305-1-5.el8 scratch build:
|
|
|
8215de |
https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=39394966
|
|
|
8215de |
|
|
|
8215de |
commit 82faab596fc8f92648f20e2fbc4211557b115c13
|
|
|
8215de |
Author: Jon Maloy <jmaloy@redhat.com>
|
|
|
8215de |
Date: Thu Aug 12 19:22:51 2021 -0400
|
|
|
8215de |
|
|
|
8215de |
KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow
|
|
|
8215de |
|
|
|
8215de |
Bugzilla: https://bugzilla.redhat.com/1988225
|
|
|
8215de |
Upstream Status: Merged
|
|
|
8215de |
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=38936146
|
|
|
8215de |
CVE: CVE-2021-37576
|
|
|
8215de |
|
|
|
8215de |
commit f62f3c20647ebd5fb6ecb8f0b477b9281c44c10a
|
|
|
8215de |
Author: Nicholas Piggin <npiggin@gmail.com>
|
|
|
8215de |
Date: Tue Jul 20 20:43:09 2021 +1000
|
|
|
8215de |
|
|
|
8215de |
KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow
|
|
|
8215de |
|
|
|
8215de |
The kvmppc_rtas_hcall() sets the host rtas_args.rets pointer based on
|
|
|
8215de |
the rtas_args.nargs that was provided by the guest. That guest nargs
|
|
|
8215de |
value is not range checked, so the guest can cause the host rets pointer
|
|
|
8215de |
to be pointed outside the args array. The individual rtas function
|
|
|
8215de |
handlers check the nargs and nrets values to ensure they are correct,
|
|
|
8215de |
but if they are not, the handlers store a -3 (0xfffffffd) failure
|
|
|
8215de |
indication in rets[0] which corrupts host memory.
|
|
|
8215de |
|
|
|
8215de |
Fix this by testing up front whether the guest supplied nargs and nret
|
|
|
8215de |
would exceed the array size, and fail the hcall directly without storing
|
|
|
8215de |
a failure indication to rets[0].
|
|
|
8215de |
|
|
|
8215de |
Also expand on a comment about why we kill the guest and try not to
|
|
|
8215de |
return errors directly if we have a valid rets[0] pointer.
|
|
|
8215de |
|
|
|
8215de |
Fixes: 8e591cb72047 ("KVM: PPC: Book3S: Add infrastructure to implement kernel-side RTAS calls")
|
|
|
8215de |
Cc: stable@vger.kernel.org # v3.10+
|
|
|
8215de |
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
|
8215de |
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
|
|
|
8215de |
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
|
|
|
8215de |
|
|
|
8215de |
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
8215de |
|
|
|
8215de |
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
|
|
|
8215de |
---
|
|
|
8215de |
arch/powerpc/kvm/book3s_rtas.c | 25 ++++++++++++++++++++++---
|
|
|
8215de |
1 file changed, 22 insertions(+), 3 deletions(-)
|
|
|
8215de |
|
|
|
8215de |
diff --git a/arch/powerpc/kvm/book3s_rtas.c b/arch/powerpc/kvm/book3s_rtas.c
|
|
|
8215de |
index ceccacbf028e..52095f765e32 100644
|
|
|
8215de |
--- a/arch/powerpc/kvm/book3s_rtas.c
|
|
|
8215de |
+++ b/arch/powerpc/kvm/book3s_rtas.c
|
|
|
8215de |
@@ -245,6 +245,17 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu)
|
|
|
8215de |
* value so we can restore it on the way out.
|
|
|
8215de |
*/
|
|
|
8215de |
orig_rets = args.rets;
|
|
|
8215de |
+ if (be32_to_cpu(args.nargs) >= ARRAY_SIZE(args.args)) {
|
|
|
8215de |
+ /*
|
|
|
8215de |
+ * Don't overflow our args array: ensure there is room for
|
|
|
8215de |
+ * at least rets[0] (even if the call specifies 0 nret).
|
|
|
8215de |
+ *
|
|
|
8215de |
+ * Each handler must then check for the correct nargs and nret
|
|
|
8215de |
+ * values, but they may always return failure in rets[0].
|
|
|
8215de |
+ */
|
|
|
8215de |
+ rc = -EINVAL;
|
|
|
8215de |
+ goto fail;
|
|
|
8215de |
+ }
|
|
|
8215de |
args.rets = &args.args[be32_to_cpu(args.nargs)];
|
|
|
8215de |
|
|
|
8215de |
mutex_lock(&vcpu->kvm->arch.rtas_token_lock);
|
|
|
8215de |
@@ -272,9 +283,17 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu)
|
|
|
8215de |
fail:
|
|
|
8215de |
/*
|
|
|
8215de |
* We only get here if the guest has called RTAS with a bogus
|
|
|
8215de |
- * args pointer. That means we can't get to the args, and so we
|
|
|
8215de |
- * can't fail the RTAS call. So fail right out to userspace,
|
|
|
8215de |
- * which should kill the guest.
|
|
|
8215de |
+ * args pointer or nargs/nret values that would overflow the
|
|
|
8215de |
+ * array. That means we can't get to the args, and so we can't
|
|
|
8215de |
+ * fail the RTAS call. So fail right out to userspace, which
|
|
|
8215de |
+ * should kill the guest.
|
|
|
8215de |
+ *
|
|
|
8215de |
+ * SLOF should actually pass the hcall return value from the
|
|
|
8215de |
+ * rtas handler call in r3, so enter_rtas could be modified to
|
|
|
8215de |
+ * return a failure indication in r3 and we could return such
|
|
|
8215de |
+ * errors to the guest rather than failing to host userspace.
|
|
|
8215de |
+ * However old guests that don't test for failure could then
|
|
|
8215de |
+ * continue silently after errors, so for now we won't do this.
|
|
|
8215de |
*/
|
|
|
8215de |
return rc;
|
|
|
8215de |
}
|
|
|
8215de |
--
|
|
|
8215de |
2.31.1
|
|
|
8215de |
|
|
|
8215de |
|