All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM
@ 2017-09-14 21:56 ` Greg Kurz
  0 siblings, 0 replies; 27+ messages in thread
From: Greg Kurz @ 2017-09-14 21:56 UTC (permalink / raw)
  To: kvm
  Cc: kvm-ppc, Paul Mackerras, David Gibson, Sam Bobroff,
	Paolo Bonzini, linuxppc-dev, stable

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")
Cc: stable@vger.kernel.org # v4.7+
Signed-off-by: Greg Kurz <groug@kaod.org>
---
 arch/powerpc/kvm/powerpc.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 3480faaf1ef8..ee279c7f4802 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -644,8 +644,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
 		break;
 #endif
 	case KVM_CAP_PPC_HTM:
-		r = cpu_has_feature(CPU_FTR_TM_COMP) &&
-		    is_kvmppc_hv_enabled(kvm);
+		r = cpu_has_feature(CPU_FTR_TM_COMP) && hv_enabled;
 		break;
 	default:
 		r = 0;

^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2017-10-14  1:24 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-14 21:56 [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM Greg Kurz
2017-09-14 21:56 ` Greg Kurz
2017-09-15  0:48 ` David Gibson
2017-09-15  0:48   ` David Gibson
2017-09-15  5:52   ` Greg Kurz
2017-09-15  5:52     ` Greg Kurz
2017-09-15  5:52     ` Greg Kurz
2017-09-15  6:54     ` Greg Kurz
2017-09-15  6:54       ` Greg Kurz
2017-09-15  8:59     ` David Gibson
2017-09-15  8:59       ` David Gibson
2017-09-18  6:16       ` Thomas Huth
2017-09-18  6:16         ` Thomas Huth
2017-10-12 11:27 ` Michael Ellerman
2017-10-12 11:27   ` Michael Ellerman
2017-10-12 12:51   ` Greg Kurz
2017-10-12 12:51     ` Greg Kurz
2017-10-12 22:20     ` David Gibson
2017-10-12 22:20       ` David Gibson
2017-10-12 23:16 ` Greg Kurz
2017-10-12 23:16   ` Greg Kurz
2017-10-13 16:14   ` Paolo Bonzini
2017-10-13 16:14     ` Paolo Bonzini
2017-10-14  1:23     ` Paul Mackerras
2017-10-14  1:23       ` Paul Mackerras
2017-10-14  1:23 ` Paul Mackerras
2017-10-14  1:23   ` Paul Mackerras

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.