Heap-use-after-free in usb_packet_unmap
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Hello,
Reproducer:
cat << EOF | ./i386-
-trace usb\* -device usb-audio -device usb-storage,
-drive id=mydrive,
-nodefaults -nographic -qtest stdio
outl 0xcf8 0x80001010
outl 0xcfc 0xc0202
outl 0xcf8 0x80001004
outl 0xcfc 0x1c77695e
writel 0xc0040 0xffffd855
writeq 0xc2000 0xff05140100000000
write 0x1d 0x1 0x27
write 0x2d 0x1 0x2e
write 0x17232 0x1 0x03
write 0x17254 0x1 0x05
write 0x17276 0x1 0x72
write 0x17278 0x1 0x02
write 0x3d 0x1 0x27
write 0x40 0x1 0x2e
write 0x41 0x1 0x72
write 0x42 0x1 0x01
write 0x4d 0x1 0x2e
write 0x4f 0x1 0x01
write 0x2007c 0x1 0xc7
writeq 0xc2000 0x5c05140100000000
write 0x20070 0x1 0x80
write 0x20078 0x1 0x08
write 0x2007c 0x1 0xfe
write 0x2007d 0x1 0x08
write 0x20081 0x1 0xff
write 0x20082 0x1 0x0b
write 0x20089 0x1 0x8c
write 0x2008d 0x1 0x04
write 0x2009d 0x1 0x10
writeq 0xc2000 0x2505ef019e092f00
EOF
20091==ERROR: AddressSanitizer: heap-use-after-free on address 0x611000045030 at pc 0x55db79edeef2 bp 0x7ffc4020b2b0 sp 0x7ffc4020b2a8
READ of size 4 at 0x611000045030 thread T0
#0 0x55db79edeef1 in usb_packet_unmap hw/usb/
#1 0x55db79ede66f in usb_packet_map hw/usb/libhw.c:54:5
#2 0x55db79f6d5f1 in xhci_setup_packet hw/usb/
#3 0x55db79f67143 in xhci_fire_
#4 0x55db79f67143 in xhci_kick_epctx hw/usb/
#5 0x55db79f8837d in xhci_doorbell_write hw/usb/
#6 0x55db792c6b8e in memory_
#7 0x55db792c658b in access_
#8 0x55db792c5d9b in memory_
#9 0x55db78d094d2 in flatview_
#10 0x55db78cfee6b in flatview_write exec.c:3216:14
#11 0x55db78cfee6b in address_space_write exec.c:3308:18
#12 0x55db793072a9 in qtest_process_
#13 0x55db79304087 in qtest_process_inbuf softmmu/
#14 0x55db7a7d7293 in fd_chr_read chardev/
#15 0x7fc5d7f1a897 in g_main_
#16 0x55db7aa571b3 in glib_pollfds_poll util/main-
#17 0x55db7aa571b3 in os_host_
#18 0x55db7aa571b3 in main_loop_wait util/main-
#19 0x55db79315008 in qemu_main_loop softmmu/vl.c:1676:9
#20 0x55db7a8860fd in main softmmu/main.c:49:5
0x611000045030 is located 48 bytes inside of 256-byte region [0x611000045000
freed by thread T0 here:
#0 0x55db78cac16d in free (build/
#1 0x55db79f7c0e8 in xhci_ep_nuke_xfers hw/usb/
#2 0x55db79f7b454 in xhci_disable_ep hw/usb/
#3 0x55db79f79af7 in xhci_disable_slot hw/usb/
#4 0x55db79f5aea3 in xhci_reset hw/usb/
#5 0x55db79f82f49 in xhci_oper_write hw/usb/
#6 0x55db792c6b8e in memory_
#7 0x55db792c658b in access_
#8 0x55db792c5d9b in memory_
#9 0x55db78d094d2 in flatview_
#10 0x55db78cfee6b in flatview_write exec.c:3216:14
#11 0x55db78cfee6b in address_space_write exec.c:3308:18
#12 0x55db78d01fe7 in address_space_unmap exec.c:3634:9
#13 0x55db79edebbb in dma_memory_unmap include/
#14 0x55db79edebbb in usb_packet_unmap hw/usb/libhw.c:65:9
#15 0x55db79ede66f in usb_packet_map hw/usb/libhw.c:54:5
#16 0x55db79f6d5f1 in xhci_setup_packet hw/usb/
#17 0x55db79f67143 in xhci_fire_
#18 0x55db79f67143 in xhci_kick_epctx hw/usb/
#19 0x55db79f8837d in xhci_doorbell_write hw/usb/
#20 0x55db792c6b8e in memory_
#21 0x55db792c658b in access_
#22 0x55db792c5d9b in memory_
#23 0x55db78d094d2 in flatview_
#24 0x55db78cfee6b in flatview_write exec.c:3216:14
#25 0x55db78cfee6b in address_space_write exec.c:3308:18
#26 0x55db793072a9 in qtest_process_
#27 0x55db79304087 in qtest_process_inbuf softmmu/
#28 0x55db7a7d7293 in fd_chr_read chardev/
#29 0x7fc5d7f1a897 in g_main_
previously allocated by thread T0 here:
#0 0x55db78cac562 in calloc (build/
#1 0x7fc5d7f20548 in g_malloc0 (/usr/lib/
#2 0x55db79f8837d in xhci_doorbell_write hw/usb/
#3 0x55db792c6b8e in memory_
#4 0x55db792c658b in access_
#5 0x55db792c5d9b in memory_
#6 0x55db78d094d2 in flatview_
#7 0x55db78cfee6b in flatview_write exec.c:3216:14
#8 0x55db78cfee6b in address_space_write exec.c:3308:18
#9 0x55db793072a9 in qtest_process_
#10 0x55db79304087 in qtest_process_inbuf softmmu/
#11 0x55db7a7d7293 in fd_chr_read chardev/
#12 0x7fc5d7f1a897 in g_main_
-Alex
tags: | added: dma-reentrancy |
On 200813 0024, Li Qiang wrote: softmmu/ qemu-system- i386 -device nec-usb-xhci \ drive=mydrive \ file=null- co://,size= 2M,format= raw,if= none \ libhw.c: 64:28 hcd-xhci. c:1618: 5 ctl_transfer hw/usb/ hcd-xhci. c:1722: 9 hcd-xhci. c:1991: 13 hcd-xhci. c:3162: 13 region_ write_accessor softmmu/ memory. c:483:5 with_adjusted_ size softmmu/ memory. c:544:18 region_ dispatch_ write softmmu/memory.c write_continue exec.c:3176:23 command softmmu/ qtest.c: 452:13 qtest.c: 710:9 char-fd. c:68:9 context_ dispatch loop.c: 217:9 main_loop_ wait util/main- loop.c: 240:5 loop.c: 516:11 ,0x611000045100 ) i386-softmmu/ qemu-system- i386+0x250e16d) hcd-xhci. c:1252: 9
> Alexander Bulekov <email address hidden> 于2020年8月13日周四 上午12:21写道:
> >
> > Public bug reported:
> >
> > Hello,
> > Reproducer:
> >
> > cat << EOF | ./i386-
> > -trace usb\* -device usb-audio -device usb-storage,
> > -drive id=mydrive,
> > -nodefaults -nographic -qtest stdio
> > outl 0xcf8 0x80001010
> > outl 0xcfc 0xc0202
> > outl 0xcf8 0x80001004
> > outl 0xcfc 0x1c77695e
> > writel 0xc0040 0xffffd855
> > writeq 0xc2000 0xff05140100000000
> > write 0x1d 0x1 0x27
> > write 0x2d 0x1 0x2e
> > write 0x17232 0x1 0x03
> > write 0x17254 0x1 0x05
> > write 0x17276 0x1 0x72
> > write 0x17278 0x1 0x02
> > write 0x3d 0x1 0x27
> > write 0x40 0x1 0x2e
> > write 0x41 0x1 0x72
> > write 0x42 0x1 0x01
> > write 0x4d 0x1 0x2e
> > write 0x4f 0x1 0x01
> > write 0x2007c 0x1 0xc7
> > writeq 0xc2000 0x5c05140100000000
> > write 0x20070 0x1 0x80
> > write 0x20078 0x1 0x08
> > write 0x2007c 0x1 0xfe
> > write 0x2007d 0x1 0x08
> > write 0x20081 0x1 0xff
> > write 0x20082 0x1 0x0b
> > write 0x20089 0x1 0x8c
> > write 0x2008d 0x1 0x04
> > write 0x2009d 0x1 0x10
> > writeq 0xc2000 0x2505ef019e092f00
> > EOF
> >
> > 20091==ERROR: AddressSanitizer: heap-use-after-free on address 0x611000045030 at pc 0x55db79edeef2 bp 0x7ffc4020b2b0 sp 0x7ffc4020b2a8
> > READ of size 4 at 0x611000045030 thread T0
> > #0 0x55db79edeef1 in usb_packet_unmap hw/usb/
> > #1 0x55db79ede66f in usb_packet_map hw/usb/libhw.c:54:5
> > #2 0x55db79f6d5f1 in xhci_setup_packet hw/usb/
> > #3 0x55db79f67143 in xhci_fire_
> > #4 0x55db79f67143 in xhci_kick_epctx hw/usb/
> > #5 0x55db79f8837d in xhci_doorbell_write hw/usb/
> > #6 0x55db792c6b8e in memory_
> > #7 0x55db792c658b in access_
> > #8 0x55db792c5d9b in memory_
> > #9 0x55db78d094d2 in flatview_
> > #10 0x55db78cfee6b in flatview_write exec.c:3216:14
> > #11 0x55db78cfee6b in address_space_write exec.c:3308:18
> > #12 0x55db793072a9 in qtest_process_
> > #13 0x55db79304087 in qtest_process_inbuf softmmu/
> > #14 0x55db7a7d7293 in fd_chr_read chardev/
> > #15 0x7fc5d7f1a897 in g_main_
> > #16 0x55db7aa571b3 in glib_pollfds_poll util/main-
> > #17 0x55db7aa571b3 in os_host_
> > #18 0x55db7aa571b3 in main_loop_wait util/main-
> > #19 0x55db79315008 in qemu_main_loop softmmu/vl.c:1676:9
> > #20 0x55db7a8860fd in main softmmu/main.c:49:5
> >
> > 0x611000045030 is located 48 bytes inside of 256-byte region [0x611000045000
> > freed by thread T0 here:
> > #0 0x55db78cac16d in free (build/
> > #1 0x55db79f7c0e8 in xhci_ep_nuke_xfers hw/usb/
> > #2 0x55db79f7b454 ...