From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [PATCH] KVM: X86: Fix NULL deref in vcpu_scan_ioapic
Date: Tue, 18 Dec 2018 22:03:08 +0100 [thread overview]
Message-ID: <a5284a1f-fa99-b0f3-4cb6-3115328aa3e8@redhat.com> (raw)
In-Reply-To: <1545014603-4109-1-git-send-email-wanpengli@tencent.com>
On 17/12/18 03:43, Wanpeng Li wrote:
> From: Wanpeng Li <wanpengli@tencent.com>
>
> Reported by syzkaller:
>
> CPU: 1 PID: 5962 Comm: syz-executor118 Not tainted 4.20.0-rc6+ #374
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> RIP: 0010:kvm_apic_hw_enabled arch/x86/kvm/lapic.h:169 [inline]
> RIP: 0010:vcpu_scan_ioapic arch/x86/kvm/x86.c:7449 [inline]
> RIP: 0010:vcpu_enter_guest arch/x86/kvm/x86.c:7602 [inline]
> RIP: 0010:vcpu_run arch/x86/kvm/x86.c:7874 [inline]
> RIP: 0010:kvm_arch_vcpu_ioctl_run+0x5296/0x7320 arch/x86/kvm/x86.c:8074
> Call Trace:
> kvm_vcpu_ioctl+0x5c8/0x1150 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2596
> vfs_ioctl fs/ioctl.c:46 [inline]
> file_ioctl fs/ioctl.c:509 [inline]
> do_vfs_ioctl+0x1de/0x1790 fs/ioctl.c:696
> ksys_ioctl+0xa9/0xd0 fs/ioctl.c:713
> __do_sys_ioctl fs/ioctl.c:720 [inline]
> __se_sys_ioctl fs/ioctl.c:718 [inline]
> __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
> do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> The reason is that the testcase writes hyperv synic HV_X64_MSR_SINT14 msr
> and triggers scan ioapic logic to load synic vectors into EOI exit bitmap.
> However, irqchip is not initialized by this simple testcase, ioapic/apic
> objects should not be accessed.
>
> This patch fixes it by also considering whether or not apic is present.
>
> Reported-by: syzbot+39810e6c400efadfef71@syzkaller.appspotmail.com
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> ---
> arch/x86/kvm/x86.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 4f786fc..c7c1197 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -7510,7 +7510,7 @@ void kvm_make_scan_ioapic_request(struct kvm *kvm)
>
> static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu)
> {
> - if (!kvm_apic_hw_enabled(vcpu->arch.apic))
> + if (!kvm_apic_present(vcpu))
> return;
>
> bitmap_zero(vcpu->arch.ioapic_handled_vectors, 256);
>
Queued, thanks.
Paolo
prev parent reply other threads:[~2018-12-18 21:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-17 2:43 Wanpeng Li
2018-12-18 21:03 ` 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=a5284a1f-fa99-b0f3-4cb6-3115328aa3e8@redhat.com \
--to=pbonzini@redhat.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rkrcmar@redhat.com \
/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®