* [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
* [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
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-09-14 21:56 ` Greg Kurz @ 2017-09-15 0:48 ` David Gibson -1 siblings, 0 replies; 27+ messages in thread From: David Gibson @ 2017-09-15 0:48 UTC (permalink / raw) To: Greg Kurz Cc: kvm, kvm-ppc, Paul Mackerras, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable [-- Attachment #1: Type: text/plain, Size: 1893 bytes --] On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: > 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> I don't think this is right. I'm pretty sure you want to fall back to hv_enabled *only when* kvm is NULL. Otherwise if you have a PR guest on an HV capable machine, this will give the wrong answer, when called for that specific VM. > --- > 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; > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-09-15 0:48 ` David Gibson 0 siblings, 0 replies; 27+ messages in thread From: David Gibson @ 2017-09-15 0:48 UTC (permalink / raw) To: Greg Kurz Cc: kvm, kvm-ppc, Paul Mackerras, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable [-- Attachment #1: Type: text/plain, Size: 1893 bytes --] On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: > 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> I don't think this is right. I'm pretty sure you want to fall back to hv_enabled *only when* kvm is NULL. Otherwise if you have a PR guest on an HV capable machine, this will give the wrong answer, when called for that specific VM. > --- > 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; > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-09-15 0:48 ` David Gibson (?) @ 2017-09-15 5:52 ` Greg Kurz -1 siblings, 0 replies; 27+ messages in thread From: Greg Kurz @ 2017-09-15 5:52 UTC (permalink / raw) To: David Gibson Cc: kvm, kvm-ppc, Paul Mackerras, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable [-- Attachment #1: Type: text/plain, Size: 3269 bytes --] Dang! The mail relay at OVH has blacklisted Paul's address :-\ <paulus@samba.org>: host smtp.samba.org[144.76.82.148] said: 550-blacklisted at zen.spamhaus.org 550 https://www.spamhaus.org/sbl/query/SBL370982 (in reply to RCPT TO command) Cc'ing Paul at ozlabs.org On Fri, 15 Sep 2017 10:48:39 +1000 David Gibson <david@gibson.dropbear.id.au> wrote: > On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: > > 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> > > I don't think this is right. I'm pretty sure you want to fall back to > hv_enabled *only when* kvm is NULL. Otherwise if you have a PR guest > on an HV capable machine, this will give the wrong answer, when called > for that specific VM. > Hmmm... this is what we get with this patch applied: open("/dev/kvm", O_RDWR) = 3 ioctl(3, KVM_CHECK_EXTENSION, 0x84) = 1 <== if HV is present ioctl(3, KVM_CREATE_VM, 0x1) = 4 <== HV ioctl(4, KVM_CHECK_EXTENSION, 0x84) = 1 ioctl(3, KVM_CREATE_VM, 0x2) = 5 <== PR ioctl(5, KVM_CHECK_EXTENSION, 0x84) = 0 The hv_enabled variable is set as follows: /* Assume we're using HV mode when the HV module is loaded */ int hv_enabled = kvmppc_hv_ops ? 1 : 0; if (kvm) { /* * Hooray - we know which VM type we're running on. Depend on * that rather than the guess above. */ hv_enabled = is_kvmppc_hv_enabled(kvm); } so we're good. :) The last sentence in the commit message is maybe^wprobably not comprehensive enough... What about the following ? The hv_enabled variable is initialized to 1 if HV is loaded or 0 otherwise. In the case KVM_CHECK_EXTENSION is used with a VM fd, hv_enabled is updated to is_kvmppc_hv_enabled(kvm). Let's use it here, like everywhere else in this function. > > --- > > 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; > > > [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-09-15 5:52 ` Greg Kurz 0 siblings, 0 replies; 27+ messages in thread From: Greg Kurz @ 2017-09-15 5:52 UTC (permalink / raw) To: David Gibson Cc: kvm, kvm-ppc, Paul Mackerras, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable [-- Attachment #1: Type: text/plain, Size: 3269 bytes --] Dang! The mail relay at OVH has blacklisted Paul's address :-\ <paulus@samba.org>: host smtp.samba.org[144.76.82.148] said: 550-blacklisted at zen.spamhaus.org 550 https://www.spamhaus.org/sbl/query/SBL370982 (in reply to RCPT TO command) Cc'ing Paul at ozlabs.org On Fri, 15 Sep 2017 10:48:39 +1000 David Gibson <david@gibson.dropbear.id.au> wrote: > On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: > > 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> > > I don't think this is right. I'm pretty sure you want to fall back to > hv_enabled *only when* kvm is NULL. Otherwise if you have a PR guest > on an HV capable machine, this will give the wrong answer, when called > for that specific VM. > Hmmm... this is what we get with this patch applied: open("/dev/kvm", O_RDWR) = 3 ioctl(3, KVM_CHECK_EXTENSION, 0x84) = 1 <== if HV is present ioctl(3, KVM_CREATE_VM, 0x1) = 4 <== HV ioctl(4, KVM_CHECK_EXTENSION, 0x84) = 1 ioctl(3, KVM_CREATE_VM, 0x2) = 5 <== PR ioctl(5, KVM_CHECK_EXTENSION, 0x84) = 0 The hv_enabled variable is set as follows: /* Assume we're using HV mode when the HV module is loaded */ int hv_enabled = kvmppc_hv_ops ? 1 : 0; if (kvm) { /* * Hooray - we know which VM type we're running on. Depend on * that rather than the guess above. */ hv_enabled = is_kvmppc_hv_enabled(kvm); } so we're good. :) The last sentence in the commit message is maybe^wprobably not comprehensive enough... What about the following ? The hv_enabled variable is initialized to 1 if HV is loaded or 0 otherwise. In the case KVM_CHECK_EXTENSION is used with a VM fd, hv_enabled is updated to is_kvmppc_hv_enabled(kvm). Let's use it here, like everywhere else in this function. > > --- > > 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; > > > [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-09-15 5:52 ` Greg Kurz 0 siblings, 0 replies; 27+ messages in thread From: Greg Kurz @ 2017-09-15 5:52 UTC (permalink / raw) To: David Gibson Cc: kvm, kvm-ppc, stable, Paolo Bonzini, linuxppc-dev, Sam Bobroff [-- Attachment #1: Type: text/plain, Size: 3269 bytes --] Dang! The mail relay at OVH has blacklisted Paul's address :-\ <paulus@samba.org>: host smtp.samba.org[144.76.82.148] said: 550-blacklisted at zen.spamhaus.org 550 https://www.spamhaus.org/sbl/query/SBL370982 (in reply to RCPT TO command) Cc'ing Paul at ozlabs.org On Fri, 15 Sep 2017 10:48:39 +1000 David Gibson <david@gibson.dropbear.id.au> wrote: > On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: > > 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> > > I don't think this is right. I'm pretty sure you want to fall back to > hv_enabled *only when* kvm is NULL. Otherwise if you have a PR guest > on an HV capable machine, this will give the wrong answer, when called > for that specific VM. > Hmmm... this is what we get with this patch applied: open("/dev/kvm", O_RDWR) = 3 ioctl(3, KVM_CHECK_EXTENSION, 0x84) = 1 <== if HV is present ioctl(3, KVM_CREATE_VM, 0x1) = 4 <== HV ioctl(4, KVM_CHECK_EXTENSION, 0x84) = 1 ioctl(3, KVM_CREATE_VM, 0x2) = 5 <== PR ioctl(5, KVM_CHECK_EXTENSION, 0x84) = 0 The hv_enabled variable is set as follows: /* Assume we're using HV mode when the HV module is loaded */ int hv_enabled = kvmppc_hv_ops ? 1 : 0; if (kvm) { /* * Hooray - we know which VM type we're running on. Depend on * that rather than the guess above. */ hv_enabled = is_kvmppc_hv_enabled(kvm); } so we're good. :) The last sentence in the commit message is maybe^wprobably not comprehensive enough... What about the following ? The hv_enabled variable is initialized to 1 if HV is loaded or 0 otherwise. In the case KVM_CHECK_EXTENSION is used with a VM fd, hv_enabled is updated to is_kvmppc_hv_enabled(kvm). Let's use it here, like everywhere else in this function. > > --- > > 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; > > > [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-09-15 5:52 ` Greg Kurz @ 2017-09-15 6:54 ` Greg Kurz -1 siblings, 0 replies; 27+ messages in thread From: Greg Kurz @ 2017-09-15 6:54 UTC (permalink / raw) To: David Gibson Cc: kvm, kvm-ppc, Paul Mackerras, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable [-- Attachment #1: Type: text/plain, Size: 423 bytes --] On Fri, 15 Sep 2017 07:52:49 +0200 Greg Kurz <groug@kaod.org> wrote: > Dang! The mail relay at OVH has blacklisted Paul's address :-\ > > <paulus@samba.org>: host smtp.samba.org[144.76.82.148] said: 550-blacklisted at > zen.spamhaus.org 550 https://www.spamhaus.org/sbl/query/SBL370982 (in reply > to RCPT TO command) > Dumb me! It's the opposite... OVH is blacklisted by smtp.samba.org :-\ Sigh. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-09-15 6:54 ` Greg Kurz 0 siblings, 0 replies; 27+ messages in thread From: Greg Kurz @ 2017-09-15 6:54 UTC (permalink / raw) To: David Gibson Cc: kvm, kvm-ppc, Paul Mackerras, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable [-- Attachment #1: Type: text/plain, Size: 423 bytes --] On Fri, 15 Sep 2017 07:52:49 +0200 Greg Kurz <groug@kaod.org> wrote: > Dang! The mail relay at OVH has blacklisted Paul's address :-\ > > <paulus@samba.org>: host smtp.samba.org[144.76.82.148] said: 550-blacklisted at > zen.spamhaus.org 550 https://www.spamhaus.org/sbl/query/SBL370982 (in reply > to RCPT TO command) > Dumb me! It's the opposite... OVH is blacklisted by smtp.samba.org :-\ Sigh. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-09-15 5:52 ` Greg Kurz @ 2017-09-15 8:59 ` David Gibson -1 siblings, 0 replies; 27+ messages in thread From: David Gibson @ 2017-09-15 8:59 UTC (permalink / raw) To: Greg Kurz Cc: kvm, kvm-ppc, Paul Mackerras, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable [-- Attachment #1: Type: text/plain, Size: 3834 bytes --] On Fri, Sep 15, 2017 at 07:52:49AM +0200, Greg Kurz wrote: > Dang! The mail relay at OVH has blacklisted Paul's address :-\ > > <paulus@samba.org>: host smtp.samba.org[144.76.82.148] said: 550-blacklisted at > zen.spamhaus.org 550 https://www.spamhaus.org/sbl/query/SBL370982 (in reply > to RCPT TO command) > > Cc'ing Paul at ozlabs.org > > On Fri, 15 Sep 2017 10:48:39 +1000 > David Gibson <david@gibson.dropbear.id.au> wrote: > > > On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: > > > 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> > > > > I don't think this is right. I'm pretty sure you want to fall back to > > hv_enabled *only when* kvm is NULL. Otherwise if you have a PR guest > > on an HV capable machine, this will give the wrong answer, when called > > for that specific VM. > > > > Hmmm... this is what we get with this patch applied: > > open("/dev/kvm", O_RDWR) = 3 > ioctl(3, KVM_CHECK_EXTENSION, 0x84) = 1 <== if HV is present > ioctl(3, KVM_CREATE_VM, 0x1) = 4 <== HV > ioctl(4, KVM_CHECK_EXTENSION, 0x84) = 1 > ioctl(3, KVM_CREATE_VM, 0x2) = 5 <== PR > ioctl(5, KVM_CHECK_EXTENSION, 0x84) = 0 > > The hv_enabled variable is set as follows: > > /* Assume we're using HV mode when the HV module is loaded */ > int hv_enabled = kvmppc_hv_ops ? 1 : 0; > > if (kvm) { > /* > * Hooray - we know which VM type we're running on. Depend on > * that rather than the guess above. > */ > hv_enabled = is_kvmppc_hv_enabled(kvm); > } > > so we're good. :) Oh, sorry, missed that bit. In that case. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> > The last sentence in the commit message is maybe^wprobably not comprehensive > enough... > > What about the following ? > > The hv_enabled variable is initialized to 1 if HV is loaded or 0 otherwise. > In the case KVM_CHECK_EXTENSION is used with a VM fd, hv_enabled is updated > to is_kvmppc_hv_enabled(kvm). Let's use it here, like everywhere else in this > function. > > > > --- > > > 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; > > > > > > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-09-15 8:59 ` David Gibson 0 siblings, 0 replies; 27+ messages in thread From: David Gibson @ 2017-09-15 8:59 UTC (permalink / raw) To: Greg Kurz Cc: kvm, kvm-ppc, Paul Mackerras, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable [-- Attachment #1: Type: text/plain, Size: 3834 bytes --] On Fri, Sep 15, 2017 at 07:52:49AM +0200, Greg Kurz wrote: > Dang! The mail relay at OVH has blacklisted Paul's address :-\ > > <paulus@samba.org>: host smtp.samba.org[144.76.82.148] said: 550-blacklisted at > zen.spamhaus.org 550 https://www.spamhaus.org/sbl/query/SBL370982 (in reply > to RCPT TO command) > > Cc'ing Paul at ozlabs.org > > On Fri, 15 Sep 2017 10:48:39 +1000 > David Gibson <david@gibson.dropbear.id.au> wrote: > > > On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: > > > 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> > > > > I don't think this is right. I'm pretty sure you want to fall back to > > hv_enabled *only when* kvm is NULL. Otherwise if you have a PR guest > > on an HV capable machine, this will give the wrong answer, when called > > for that specific VM. > > > > Hmmm... this is what we get with this patch applied: > > open("/dev/kvm", O_RDWR) = 3 > ioctl(3, KVM_CHECK_EXTENSION, 0x84) = 1 <== if HV is present > ioctl(3, KVM_CREATE_VM, 0x1) = 4 <== HV > ioctl(4, KVM_CHECK_EXTENSION, 0x84) = 1 > ioctl(3, KVM_CREATE_VM, 0x2) = 5 <== PR > ioctl(5, KVM_CHECK_EXTENSION, 0x84) = 0 > > The hv_enabled variable is set as follows: > > /* Assume we're using HV mode when the HV module is loaded */ > int hv_enabled = kvmppc_hv_ops ? 1 : 0; > > if (kvm) { > /* > * Hooray - we know which VM type we're running on. Depend on > * that rather than the guess above. > */ > hv_enabled = is_kvmppc_hv_enabled(kvm); > } > > so we're good. :) Oh, sorry, missed that bit. In that case. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> > The last sentence in the commit message is maybe^wprobably not comprehensive > enough... > > What about the following ? > > The hv_enabled variable is initialized to 1 if HV is loaded or 0 otherwise. > In the case KVM_CHECK_EXTENSION is used with a VM fd, hv_enabled is updated > to is_kvmppc_hv_enabled(kvm). Let's use it here, like everywhere else in this > function. > > > > --- > > > 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; > > > > > > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-09-15 8:59 ` David Gibson @ 2017-09-18 6:16 ` Thomas Huth -1 siblings, 0 replies; 27+ messages in thread From: Thomas Huth @ 2017-09-18 6:16 UTC (permalink / raw) To: David Gibson, Greg Kurz Cc: kvm, kvm-ppc, Paul Mackerras, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable [-- Attachment #1: Type: text/plain, Size: 2651 bytes --] On 15.09.2017 10:59, David Gibson wrote: > On Fri, Sep 15, 2017 at 07:52:49AM +0200, Greg Kurz wrote: >> Dang! The mail relay at OVH has blacklisted Paul's address :-\ >> >> <paulus@samba.org>: host smtp.samba.org[144.76.82.148] said: 550-blacklisted at >> zen.spamhaus.org 550 https://www.spamhaus.org/sbl/query/SBL370982 (in reply >> to RCPT TO command) >> >> Cc'ing Paul at ozlabs.org >> >> On Fri, 15 Sep 2017 10:48:39 +1000 >> David Gibson <david@gibson.dropbear.id.au> wrote: >> >>> On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: >>>> 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> >>> >>> I don't think this is right. I'm pretty sure you want to fall back to >>> hv_enabled *only when* kvm is NULL. Otherwise if you have a PR guest >>> on an HV capable machine, this will give the wrong answer, when called >>> for that specific VM. >>> >> >> Hmmm... this is what we get with this patch applied: >> >> open("/dev/kvm", O_RDWR) = 3 >> ioctl(3, KVM_CHECK_EXTENSION, 0x84) = 1 <== if HV is present >> ioctl(3, KVM_CREATE_VM, 0x1) = 4 <== HV >> ioctl(4, KVM_CHECK_EXTENSION, 0x84) = 1 >> ioctl(3, KVM_CREATE_VM, 0x2) = 5 <== PR >> ioctl(5, KVM_CHECK_EXTENSION, 0x84) = 0 >> >> The hv_enabled variable is set as follows: >> >> /* Assume we're using HV mode when the HV module is loaded */ >> int hv_enabled = kvmppc_hv_ops ? 1 : 0; >> >> if (kvm) { >> /* >> * Hooray - we know which VM type we're running on. Depend on >> * that rather than the guess above. >> */ >> hv_enabled = is_kvmppc_hv_enabled(kvm); >> } >> >> so we're good. :) > > Oh, sorry, missed that bit. In that case. > > Reviewed-by: David Gibson <david@gibson.dropbear.id.au> LGTM, too: Reviewed-by: Thomas Huth <thuth@redhat.com> [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-09-18 6:16 ` Thomas Huth 0 siblings, 0 replies; 27+ messages in thread From: Thomas Huth @ 2017-09-18 6:16 UTC (permalink / raw) To: David Gibson, Greg Kurz Cc: kvm, kvm-ppc, Paul Mackerras, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable [-- Attachment #1: Type: text/plain, Size: 2651 bytes --] On 15.09.2017 10:59, David Gibson wrote: > On Fri, Sep 15, 2017 at 07:52:49AM +0200, Greg Kurz wrote: >> Dang! The mail relay at OVH has blacklisted Paul's address :-\ >> >> <paulus@samba.org>: host smtp.samba.org[144.76.82.148] said: 550-blacklisted at >> zen.spamhaus.org 550 https://www.spamhaus.org/sbl/query/SBL370982 (in reply >> to RCPT TO command) >> >> Cc'ing Paul at ozlabs.org >> >> On Fri, 15 Sep 2017 10:48:39 +1000 >> David Gibson <david@gibson.dropbear.id.au> wrote: >> >>> On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: >>>> 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> >>> >>> I don't think this is right. I'm pretty sure you want to fall back to >>> hv_enabled *only when* kvm is NULL. Otherwise if you have a PR guest >>> on an HV capable machine, this will give the wrong answer, when called >>> for that specific VM. >>> >> >> Hmmm... this is what we get with this patch applied: >> >> open("/dev/kvm", O_RDWR) = 3 >> ioctl(3, KVM_CHECK_EXTENSION, 0x84) = 1 <== if HV is present >> ioctl(3, KVM_CREATE_VM, 0x1) = 4 <== HV >> ioctl(4, KVM_CHECK_EXTENSION, 0x84) = 1 >> ioctl(3, KVM_CREATE_VM, 0x2) = 5 <== PR >> ioctl(5, KVM_CHECK_EXTENSION, 0x84) = 0 >> >> The hv_enabled variable is set as follows: >> >> /* Assume we're using HV mode when the HV module is loaded */ >> int hv_enabled = kvmppc_hv_ops ? 1 : 0; >> >> if (kvm) { >> /* >> * Hooray - we know which VM type we're running on. Depend on >> * that rather than the guess above. >> */ >> hv_enabled = is_kvmppc_hv_enabled(kvm); >> } >> >> so we're good. :) > > Oh, sorry, missed that bit. In that case. > > Reviewed-by: David Gibson <david@gibson.dropbear.id.au> LGTM, too: Reviewed-by: Thomas Huth <thuth@redhat.com> [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-09-14 21:56 ` Greg Kurz @ 2017-10-12 11:27 ` Michael Ellerman -1 siblings, 0 replies; 27+ messages in thread From: Michael Ellerman @ 2017-10-12 11:27 UTC (permalink / raw) To: Greg Kurz, kvm Cc: kvm-ppc, Paul Mackerras, stable, Paolo Bonzini, linuxppc-dev, Sam Bobroff, David Gibson Greg Kurz <groug@kaod.org> writes: > 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; Did this go anywhere? cheers ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-10-12 11:27 ` Michael Ellerman 0 siblings, 0 replies; 27+ messages in thread From: Michael Ellerman @ 2017-10-12 11:27 UTC (permalink / raw) To: Greg Kurz, kvm Cc: kvm-ppc, Paul Mackerras, stable, Paolo Bonzini, linuxppc-dev, Sam Bobroff, David Gibson Greg Kurz <groug@kaod.org> writes: > 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; Did this go anywhere? cheers ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-10-12 11:27 ` Michael Ellerman @ 2017-10-12 12:51 ` Greg Kurz -1 siblings, 0 replies; 27+ messages in thread From: Greg Kurz @ 2017-10-12 12:51 UTC (permalink / raw) To: Michael Ellerman Cc: kvm, kvm-ppc, Paul Mackerras, stable, Paolo Bonzini, linuxppc-dev, Sam Bobroff, David Gibson On Thu, 12 Oct 2017 22:27:54 +1100 Michael Ellerman <mpe@ellerman.id.au> wrote: > Greg Kurz <groug@kaod.org> writes: > > 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; > > Did this go anywhere? > > cheers I'm afraid not... and I haven't tried to ping Paul yet, since he's supposed to be on vacation from what I've been told. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-10-12 12:51 ` Greg Kurz 0 siblings, 0 replies; 27+ messages in thread From: Greg Kurz @ 2017-10-12 12:51 UTC (permalink / raw) To: Michael Ellerman Cc: kvm, kvm-ppc, Paul Mackerras, stable, Paolo Bonzini, linuxppc-dev, Sam Bobroff, David Gibson On Thu, 12 Oct 2017 22:27:54 +1100 Michael Ellerman <mpe@ellerman.id.au> wrote: > Greg Kurz <groug@kaod.org> writes: > > 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; > > Did this go anywhere? > > cheers I'm afraid not... and I haven't tried to ping Paul yet, since he's supposed to be on vacation from what I've been told. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-10-12 12:51 ` Greg Kurz @ 2017-10-12 22:20 ` David Gibson -1 siblings, 0 replies; 27+ messages in thread From: David Gibson @ 2017-10-12 22:20 UTC (permalink / raw) To: Greg Kurz Cc: Michael Ellerman, kvm, kvm-ppc, Paul Mackerras, stable, Paolo Bonzini, linuxppc-dev, Sam Bobroff [-- Attachment #1: Type: text/plain, Size: 2144 bytes --] On Thu, Oct 12, 2017 at 02:51:57PM +0200, Greg Kurz wrote: > On Thu, 12 Oct 2017 22:27:54 +1100 > Michael Ellerman <mpe@ellerman.id.au> wrote: > > > Greg Kurz <groug@kaod.org> writes: > > > 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; > > > > Did this go anywhere? > > > > cheers > > I'm afraid not... and I haven't tried to ping Paul yet, since he's > supposed to be on vacation from what I've been told. He's back now. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-10-12 22:20 ` David Gibson 0 siblings, 0 replies; 27+ messages in thread From: David Gibson @ 2017-10-12 22:20 UTC (permalink / raw) To: Greg Kurz Cc: Michael Ellerman, kvm, kvm-ppc, Paul Mackerras, stable, Paolo Bonzini, linuxppc-dev, Sam Bobroff [-- Attachment #1: Type: text/plain, Size: 2144 bytes --] On Thu, Oct 12, 2017 at 02:51:57PM +0200, Greg Kurz wrote: > On Thu, 12 Oct 2017 22:27:54 +1100 > Michael Ellerman <mpe@ellerman.id.au> wrote: > > > Greg Kurz <groug@kaod.org> writes: > > > 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; > > > > Did this go anywhere? > > > > cheers > > I'm afraid not... and I haven't tried to ping Paul yet, since he's > supposed to be on vacation from what I've been told. He's back now. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-09-14 21:56 ` Greg Kurz @ 2017-10-12 23:16 ` Greg Kurz -1 siblings, 0 replies; 27+ messages in thread From: Greg Kurz @ 2017-10-12 23:16 UTC (permalink / raw) To: kvm Cc: kvm-ppc, Paul Mackerras, David Gibson, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable Ping ? On Thu, 14 Sep 2017 23:56:25 +0200 Greg Kurz <groug@kaod.org> wrote: > 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; > > -- > 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 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-10-12 23:16 ` Greg Kurz 0 siblings, 0 replies; 27+ messages in thread From: Greg Kurz @ 2017-10-12 23:16 UTC (permalink / raw) To: kvm Cc: kvm-ppc, Paul Mackerras, David Gibson, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable Ping ? On Thu, 14 Sep 2017 23:56:25 +0200 Greg Kurz <groug@kaod.org> wrote: > 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; > > -- > 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 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-10-12 23:16 ` Greg Kurz @ 2017-10-13 16:14 ` Paolo Bonzini -1 siblings, 0 replies; 27+ messages in thread From: Paolo Bonzini @ 2017-10-13 16:14 UTC (permalink / raw) To: Greg Kurz, kvm Cc: kvm-ppc, Paul Mackerras, David Gibson, Sam Bobroff, linuxppc-dev, stable On 13/10/2017 01:16, Greg Kurz wrote: > Ping ? When is Paul back from vacation? :) Paolo > On Thu, 14 Sep 2017 23:56:25 +0200 > Greg Kurz <groug@kaod.org> wrote: > >> 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; >> >> -- >> 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 > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-10-13 16:14 ` Paolo Bonzini 0 siblings, 0 replies; 27+ messages in thread From: Paolo Bonzini @ 2017-10-13 16:14 UTC (permalink / raw) To: Greg Kurz, kvm Cc: kvm-ppc, Paul Mackerras, David Gibson, Sam Bobroff, linuxppc-dev, stable On 13/10/2017 01:16, Greg Kurz wrote: > Ping ? When is Paul back from vacation? :) Paolo > On Thu, 14 Sep 2017 23:56:25 +0200 > Greg Kurz <groug@kaod.org> wrote: > >> 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; >> >> -- >> 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 > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-10-13 16:14 ` Paolo Bonzini @ 2017-10-14 1:23 ` Paul Mackerras -1 siblings, 0 replies; 27+ messages in thread From: Paul Mackerras @ 2017-10-14 1:23 UTC (permalink / raw) To: Paolo Bonzini Cc: Greg Kurz, kvm, kvm-ppc, David Gibson, Sam Bobroff, linuxppc-dev, stable On Fri, Oct 13, 2017 at 06:14:00PM +0200, Paolo Bonzini wrote: > On 13/10/2017 01:16, Greg Kurz wrote: > > Ping ? > > When is Paul back from vacation? :) Now. :) Paul. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-10-14 1:23 ` Paul Mackerras 0 siblings, 0 replies; 27+ messages in thread From: Paul Mackerras @ 2017-10-14 1:23 UTC (permalink / raw) To: Paolo Bonzini Cc: Greg Kurz, kvm, kvm-ppc, David Gibson, Sam Bobroff, linuxppc-dev, stable On Fri, Oct 13, 2017 at 06:14:00PM +0200, Paolo Bonzini wrote: > On 13/10/2017 01:16, Greg Kurz wrote: > > Ping ? > > When is Paul back from vacation? :) Now. :) Paul. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM 2017-09-14 21:56 ` Greg Kurz @ 2017-10-14 1:23 ` Paul Mackerras -1 siblings, 0 replies; 27+ messages in thread From: Paul Mackerras @ 2017-10-14 1:23 UTC (permalink / raw) To: Greg Kurz Cc: kvm, kvm-ppc, David Gibson, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: > 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> Thanks, applied to my kvm-ppc-fixes branch. Paul. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH] KVM: PPC: fix oops when checking KVM_CAP_PPC_HTM @ 2017-10-14 1:23 ` Paul Mackerras 0 siblings, 0 replies; 27+ messages in thread From: Paul Mackerras @ 2017-10-14 1:23 UTC (permalink / raw) To: Greg Kurz Cc: kvm, kvm-ppc, David Gibson, Sam Bobroff, Paolo Bonzini, linuxppc-dev, stable On Thu, Sep 14, 2017 at 11:56:25PM +0200, Greg Kurz wrote: > 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> Thanks, applied to my kvm-ppc-fixes branch. Paul. ^ permalink raw reply [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.