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>,
"Dmitry Vyukov" <dvyukov@google.com>,
"Wanpeng Li" <wanpeng.li@hotmail.com>
Subject: Re: [PATCH] KVM: ioapic: fix NULL deref ioapic->lock
Date: Mon, 2 Jan 2017 11:09:14 +0100 [thread overview]
Message-ID: <f3d9f26b-477d-fa3f-38f6-65913853bdf4@redhat.com> (raw)
In-Reply-To: <1483242289-12323-1-git-send-email-wanpeng.li@hotmail.com>
On 01/01/2017 04:44, Wanpeng Li wrote:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> This was reported by syzkaller:
>
> BUG: unable to handle kernel NULL pointer dereference at 00000000000001b0
> IP: _raw_spin_lock+0xc/0x30
> PGD 3e28eb067
> PUD 3f0ac6067
> PMD 0
> Oops: 0002 [#1] SMP
> CPU: 0 PID: 2431 Comm: test Tainted: G OE 4.10.0-rc1+ #3
> Call Trace:
> ? kvm_ioapic_scan_entry+0x3e/0x110 [kvm]
> kvm_arch_vcpu_ioctl_run+0x10a8/0x15f0 [kvm]
> ? pick_next_task_fair+0xe1/0x4e0
> ? kvm_arch_vcpu_load+0xea/0x260 [kvm]
> kvm_vcpu_ioctl+0x33a/0x600 [kvm]
> ? hrtimer_try_to_cancel+0x29/0x130
> ? do_nanosleep+0x97/0xf0
> do_vfs_ioctl+0xa1/0x5d0
> ? __hrtimer_init+0x90/0x90
> ? do_nanosleep+0x5b/0xf0
> SyS_ioctl+0x79/0x90
> do_syscall_64+0x6e/0x180
> entry_SYSCALL64_slow_path+0x25/0x25
> RIP: _raw_spin_lock+0xc/0x30 RSP: ffffa43688973cc0
>
> KVM will skip over create pic/ioapic if there is a created vCPU. However,
> there is no guarantee whether ioapic is present when rescan ioapic which
> results in NULL dereference ioapic->lock. This patch fix it by adding the
> ioapic present check to ioapic scan.
>
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> arch/x86/kvm/x86.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 51ccfe0..9ca175c 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6556,7 +6556,8 @@ static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu)
> else {
> if (vcpu->arch.apicv_active)
> kvm_x86_ops->sync_pir_to_irr(vcpu);
> - kvm_ioapic_scan_entry(vcpu, vcpu->arch.ioapic_handled_vectors);
> + if (ioapic_irqchip(vcpu->kvm))
> + kvm_ioapic_scan_entry(vcpu, vcpu->arch.ioapic_handled_vectors);
> }
> bitmap_or((ulong *)eoi_exit_bitmap, vcpu->arch.ioapic_handled_vectors,
> vcpu_to_synic(vcpu)->vec_bitmap, 256);
Commit message for fuzzing bugs have usually included a beautified
reproducer. However, you are not even saying if it is a race, or it is
deterministic.
The fix seems wrong to me at first impression, because "LAPIC enabled"
and "irqchip not split" should imply the existence of an in-kernel
IOAPIC. However, I cannot suggest the right course of action without
seeing a testcase.
Paolo
next prev parent reply other threads:[~2017-01-02 10:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-01 3:44 Wanpeng Li
2017-01-02 10:09 ` Paolo Bonzini [this message]
2017-01-02 10:17 ` Dmitry Vyukov
2017-01-02 18:01 ` Paolo Bonzini
2017-01-02 22:37 ` Wanpeng Li
2017-01-03 9:27 ` Dmitry Vyukov
2017-01-03 10:40 ` Wanpeng Li
2017-01-03 12:06 ` David Hildenbrand
2017-01-03 17:23 ` Paolo Bonzini
2017-01-03 22:03 ` Wanpeng Li
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=f3d9f26b-477d-fa3f-38f6-65913853bdf4@redhat.com \
--to=pbonzini@redhat.com \
--cc=dvyukov@google.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rkrcmar@redhat.com \
--cc=wanpeng.li@hotmail.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®