qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] ioapic: use irq number instead of vector in


From: Li Qiang
Subject: Re: [Qemu-devel] [PATCH v2] ioapic: use irq number instead of vector in ioapic_eoi_broadcast
Date: Mon, 24 Jun 2019 19:08:30 +0800

Peter Xu <address@hidden> 于2019年6月24日周一 下午5:42写道:

> On Fri, Jun 21, 2019 at 05:21:19PM -0700, Li Qiang wrote:
> > When emulating irqchip in qemu, such as following command:
> >
> > x86_64-softmmu/qemu-system-x86_64 -m 1024 -smp 4 -hda /home/test/test.img
> > -machine kernel-irqchip=off --enable-kvm -vnc :0 -device edu -monitor
> stdio
> >
> > We will get a crash with following asan output:
> >
> > (qemu) /home/test/qemu5/qemu/hw/intc/ioapic.c:266:27: runtime error:
> index 35 out of bounds for type 'int [24]'
> > =================================================================
> > ==113504==ERROR: AddressSanitizer: heap-buffer-overflow on address
> 0x61b000003114 at pc 0x5579e3c7a80f bp 0x7fd004bf8c10 sp 0x7fd004bf8c00
> > WRITE of size 4 at 0x61b000003114 thread T4
> >     #0 0x5579e3c7a80e in ioapic_eoi_broadcast
> /home/test/qemu5/qemu/hw/intc/ioapic.c:266
> >     #1 0x5579e3c6f480 in apic_eoi
> /home/test/qemu5/qemu/hw/intc/apic.c:428
> >     #2 0x5579e3c720a7 in apic_mem_write
> /home/test/qemu5/qemu/hw/intc/apic.c:802
> >     #3 0x5579e3b1e31a in memory_region_write_accessor
> /home/test/qemu5/qemu/memory.c:503
> >     #4 0x5579e3b1e6a2 in access_with_adjusted_size
> /home/test/qemu5/qemu/memory.c:569
> >     #5 0x5579e3b28d77 in memory_region_dispatch_write
> /home/test/qemu5/qemu/memory.c:1497
> >     #6 0x5579e3a1b36b in flatview_write_continue
> /home/test/qemu5/qemu/exec.c:3323
> >     #7 0x5579e3a1b633 in flatview_write /home/test/qemu5/qemu/exec.c:3362
> >     #8 0x5579e3a1bcb1 in address_space_write
> /home/test/qemu5/qemu/exec.c:3452
> >     #9 0x5579e3a1bd03 in address_space_rw
> /home/test/qemu5/qemu/exec.c:3463
> >     #10 0x5579e3b8b979 in kvm_cpu_exec
> /home/test/qemu5/qemu/accel/kvm/kvm-all.c:2045
> >     #11 0x5579e3ae4499 in qemu_kvm_cpu_thread_fn
> /home/test/qemu5/qemu/cpus.c:1287
> >     #12 0x5579e4cbdb9f in qemu_thread_start util/qemu-thread-posix.c:502
> >     #13 0x7fd0146376da in start_thread
> (/lib/x86_64-linux-gnu/libpthread.so.0+0x76da)
> >     #14 0x7fd01436088e in __clone
> (/lib/x86_64-linux-gnu/libc.so.6+0x12188e
> >
> > This is because in ioapic_eoi_broadcast function, we uses 'vector' to
> > index the 's->irq_eoi'. To fix this, we should uses the irq number.
> >
> > Signed-off-by: Li Qiang <address@hidden>
>
> Reviewed-by: Peter Xu <address@hidden>
>
>
Thanks Peter.



> Maybe also add:
>
> Fixes: 958a01dab8 ("ioapic: allow buggy guests mishandling ...")
>
> Should we better clear irq_eoi when the entries are updated in
> ioapic_mem_write()?
>
>
Do you mean the redirect table entry of ioapic update?
I think this is reasonable, I will prepare a separate patch with this one
as a patchset later.

Thanks,
Li Qiang



> Regards,
>
> --
> Peter Xu
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]