]> git.itanic.dy.fi Git - linux-stable/commit
KVM: PPC: Fix oops when checking KVM_CAP_PPC_HTM
authorGreg Kurz <groug@kaod.org>
Thu, 14 Sep 2017 21:56:25 +0000 (23:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Nov 2017 08:49:13 +0000 (09:49 +0100)
commit474cb9e0f02fdabadfc5ecc17b9afbb0ca6aa15a
tree9206491a767eeb5292ffcd461fc4b39208e54666
parent659b04ad201b6ce71bdced1653e41c9944066f40
KVM: PPC: Fix oops when checking KVM_CAP_PPC_HTM

commit ac64115a66c18c01745bbd3c47a36b124e5fd8c0 upstream.

The following program causes a kernel oops:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/kvm.h>

main()
{
    int fd = open("/dev/kvm", O_RDWR);
    ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_PPC_HTM);
}

This happens because when using the global KVM fd with
KVM_CHECK_EXTENSION, kvm_vm_ioctl_check_extension() gets
called with a NULL kvm argument, which gets dereferenced
in is_kvmppc_hv_enabled(). Spotted while reading the code.

Let's use the hv_enabled fallback variable, like everywhere
else in this function.

Fixes: 23528bb21ee2 ("KVM: PPC: Introduce KVM_CAP_PPC_HTM")
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/kvm/powerpc.c