From: Paolo Bonzini <pbonzini@redhat.com>
To: Jon Cargille <jcargill@google.com>,
Sean Christopherson <sean.j.christopherson@intel.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Steve Rutherford <srutherford@google.com>
Subject: Re: [PATCH] KVM: Remove CREATE_IRQCHIP/SET_PIT2 race
Date: Fri, 17 Apr 2020 17:06:10 +0200 [thread overview]
Message-ID: <f7b8ca30-21fa-5268-7f17-889f10b90187@redhat.com> (raw)
In-Reply-To: <20200416191152.259434-1-jcargill@google.com>
On 16/04/20 21:11, Jon Cargille wrote:
> From: Steve Rutherford <srutherford@google.com>
>
> Fixes a NULL pointer dereference, caused by the PIT firing an interrupt
> before the interrupt table has been initialized.
>
> SET_PIT2 can race with the creation of the IRQchip. In particular,
> if SET_PIT2 is called with a low PIT timer period (after the creation of
> the IOAPIC, but before the instantiation of the irq routes), the PIT can
> fire an interrupt at an uninitialized table.
>
> Signed-off-by: Steve Rutherford <srutherford@google.com>
> Signed-off-by: Jon Cargille <jcargill@google.com>
> Reviewed-by: Jim Mattson <jmattson@google.com>
> ---
> arch/x86/kvm/x86.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 027dfd278a973..3cc3f673785c8 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -5049,10 +5049,13 @@ long kvm_arch_vm_ioctl(struct file *filp,
> r = -EFAULT;
> if (copy_from_user(&u.ps, argp, sizeof(u.ps)))
> goto out;
> + mutex_lock(&kvm->lock);
> r = -ENXIO;
> if (!kvm->arch.vpit)
> - goto out;
> + goto set_pit_out;
> r = kvm_vm_ioctl_set_pit(kvm, &u.ps);
> +set_pit_out:
> + mutex_unlock(&kvm->lock);
> break;
> }
> case KVM_GET_PIT2: {
> @@ -5072,10 +5075,13 @@ long kvm_arch_vm_ioctl(struct file *filp,
> r = -EFAULT;
> if (copy_from_user(&u.ps2, argp, sizeof(u.ps2)))
> goto out;
> + mutex_lock(&kvm->lock);
> r = -ENXIO;
> if (!kvm->arch.vpit)
> - goto out;
> + goto set_pit2_out;
> r = kvm_vm_ioctl_set_pit2(kvm, &u.ps2);
> +set_pit2_out:
> + mutex_unlock(&kvm->lock);
> break;
> }
> case KVM_REINJECT_CONTROL: {
>
Queued, thanks.
Paolo
prev parent reply other threads:[~2020-04-17 15:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-16 19:11 Jon Cargille
2020-04-17 15:06 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f7b8ca30-21fa-5268-7f17-889f10b90187@redhat.com \
--to=pbonzini@redhat.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jcargill@google.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=srutherford@google.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®