Skip to content

Commit ac64115

Browse files
gkurzpaulusmack
authored andcommitted
KVM: PPC: Fix oops when checking KVM_CAP_PPC_HTM
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: 23528bb ("KVM: PPC: Introduce KVM_CAP_PPC_HTM") Cc: [email protected] # v4.7+ Signed-off-by: Greg Kurz <[email protected]> Reviewed-by: David Gibson <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 8a5776a commit ac64115

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

arch/powerpc/kvm/powerpc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
644644
break;
645645
#endif
646646
case KVM_CAP_PPC_HTM:
647-
r = cpu_has_feature(CPU_FTR_TM_COMP) &&
648-
is_kvmppc_hv_enabled(kvm);
647+
r = cpu_has_feature(CPU_FTR_TM_COMP) && hv_enabled;
649648
break;
650649
default:
651650
r = 0;

0 commit comments

Comments
 (0)