summaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-10-26 09:45:46 -0400
committerKees Cook <keescook@chromium.org>2018-01-15 15:08:07 -0500
commit46515736f8687c5dbde5637ca2f2678055c9c0f7 (patch)
treedc606a9321bb99525c243973734447d2c8cd1b4a /virt
parent08626a6056aad824c43d34ce587ab2b01f49d1a4 (diff)
kvm: whitelist struct kvm_vcpu_arch
On x86, ARM and s390, struct kvm_vcpu_arch has a usercopy region that is read and written by the KVM_GET/SET_CPUID2 ioctls (x86) or KVM_GET/SET_ONE_REG (ARM/s390). Without whitelisting the area, KVM is completely broken on those architectures with usercopy hardening enabled. For now, allow writing to the entire struct on all architectures. The KVM tree will not refine this to an architecture-specific subset of struct kvm_vcpu_arch. Cc: kernel-hardening@lists.openwall.com Cc: Kees Cook <keescook@chromium.org> Cc: Christian Borntraeger <borntraeger@redhat.com> Cc: Christoffer Dall <cdall@linaro.org> Cc: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Christoffer Dall <christoffer.dall@linaro.org> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index c422c10cd1dd..96689967f5c3 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -4029,8 +4029,12 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
4029 /* A kmem cache lets us meet the alignment requirements of fx_save. */ 4029 /* A kmem cache lets us meet the alignment requirements of fx_save. */
4030 if (!vcpu_align) 4030 if (!vcpu_align)
4031 vcpu_align = __alignof__(struct kvm_vcpu); 4031 vcpu_align = __alignof__(struct kvm_vcpu);
4032 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align, 4032 kvm_vcpu_cache =
4033 SLAB_ACCOUNT, NULL); 4033 kmem_cache_create_usercopy("kvm_vcpu", vcpu_size, vcpu_align,
4034 SLAB_ACCOUNT,
4035 offsetof(struct kvm_vcpu, arch),
4036 sizeof_field(struct kvm_vcpu, arch),
4037 NULL);
4034 if (!kvm_vcpu_cache) { 4038 if (!kvm_vcpu_cache) {
4035 r = -ENOMEM; 4039 r = -ENOMEM;
4036 goto out_free_3; 4040 goto out_free_3;