From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from 2.mo5.mail-out.ovh.net ([178.33.109.111]:44840 "EHLO 2.mo5.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751168AbdJLXYb (ORCPT ); Thu, 12 Oct 2017 19:24:31 -0400 Received: from player773.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 755B713F7DC for ; Fri, 13 Oct 2017 01:17:08 +0200 (CEST) Date: Fri, 13 Oct 2017 01:16:51 +0200 From: Greg Kurz To: kvm@vger.kernel.org Cc: kvm-ppc@vger.kernel.org, Paul Mackerras , David Gibson , Sam Bobroff , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org, stable@vger.kernel.org Subject: Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM Message-ID: <20171013011651.35b2de97@bahia.lab.toulouse-stg.fr.ibm.com> In-Reply-To: <150542618501.6859.11512107352972110416.stgit@bahia.lan> References: <150542618501.6859.11512107352972110416.stgit@bahia.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: Ping ? On Thu, 14 Sep 2017 23:56:25 +0200 Greg Kurz wrote: > The following program causes a kernel oops: > > #include > #include > #include > #include > #include > > 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 > --- > 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; > > -- > To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg Kurz Date: Thu, 12 Oct 2017 23:16:51 +0000 Subject: Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM Message-Id: <20171013011651.35b2de97@bahia.lab.toulouse-stg.fr.ibm.com> List-Id: References: <150542618501.6859.11512107352972110416.stgit@bahia.lan> In-Reply-To: <150542618501.6859.11512107352972110416.stgit@bahia.lan> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org Cc: kvm-ppc@vger.kernel.org, Paul Mackerras , David Gibson , Sam Bobroff , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org, stable@vger.kernel.org Ping ? On Thu, 14 Sep 2017 23:56:25 +0200 Greg Kurz wrote: > The following program causes a kernel oops: > > #include > #include > #include > #include > #include > > 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 > --- > 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; > > -- > To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html