Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMJs5B8w-G8EAXBnLUJ7YkfVExJYWtdJP0B51hactD4Eett_QQ@mail.gmail.com>
Date: Thu, 26 Oct 2017 16:21:59 +0200
From: Christoffer Dall <christoffer.dall@...aro.org>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, 
	"kvm@...r.kernel.org" <kvm@...r.kernel.org>, Marc Zyngier <marc.zyngier@....com>, 
	Christian Borntraeger <borntraeger@...ibm.com>, Cornelia Huck <cohuck@...hat.com>, 
	James Hogan <james.hogan@...tec.com>, Paul Mackerras <paulus@...ba.org>, 
	kernel-hardening@...ts.openwall.com, Kees Cook <keescook@...omium.org>, 
	Christian Borntraeger <borntraeger@...hat.com>, Radim Krčmář <rkrcmar@...hat.com>
Subject: Re: [PATCH 1/2] kvm: whitelist struct kvm_vcpu_arch

On Thu, Oct 26, 2017 at 3:45 PM, Paolo Bonzini <pbonzini@...hat.com> wrote:
> On x86, ARM and s390, struct kvm_vcpu_arch has a usercopy region
> taht 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@...ts.openwall.com
> Cc: Kees Cook <keescook@...omium.org>
> Cc: Christian Borntraeger <borntraeger@...hat.com>
> Cc: Christoffer Dall <cdall@...aro.org>
> Cc: Radim Krčmář <rkrcmar@...hat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
> ---
>  virt/kvm/kvm_main.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 4d81f6ded88e..b4809ccfdfa1 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -4005,8 +4005,12 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
>         /* A kmem cache lets us meet the alignment requirements of fx_save. */
>         if (!vcpu_align)
>                 vcpu_align = __alignof__(struct kvm_vcpu);
> -       kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
> -                                          0, NULL);
> +       kvm_vcpu_cache =
> +               kmem_cache_create_usercopy("kvm_vcpu",
> +                                          sizeof(struct kvm_vcpu), vcpu_align,
> +                                          0, offsetof(struct kvm_vcpu, arch),
> +                                          sizeof_field(struct kvm_vcpu, arch),
> +                                          NULL);
>         if (!kvm_vcpu_cache) {
>                 r = -ENOMEM;
>                 goto out_free_3;
> --
> 2.14.2

Acked-by: Christoffer Dall <christoffer.dall@...aro.org>

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.