Assertion failure in fifo8_push_all() through am53c974
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Hello,
Using hypervisor fuzzer, hyfuzz, I found an assertion failure through am53c974 emulator.
A malicious guest user/process could use this flaw to abort the QEMU process on the host, resulting in a denial of service.
This was found in version 5.2.0 (master, 3f8d1885e4)
```
qemu-system-i386: ../util/fifo8.c:43: fifo8_push_all: Assertion `fifo->num + num <= fifo->capacity' failed.
#0 0x00007ffff0218fb7 in __GI_raise (sig=sig@entry=0x6) at ../sysdeps/
#1 0x00007ffff021a921 in __GI_abort () at abort.c:79
#2 0x00007ffff020a48a in __assert_fail_base (fmt=0x7ffff0391750 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=
at assert.c:92
#3 0x00007ffff020a502 in __GI___assert_fail (assertion=
#4 0x00005555587749c4 in fifo8_push_all (fifo=fifo@
#5 0x00005555572bd13e in esp_do_dma (s=s@entry=
#6 0x00005555572bfc8f in handle_ti (s=0x61f000005088) at ../hw/scsi/
#7 0x00005555572c419c in esp_reg_write (s=0x61f000005088, saddr=saddr@
at ../hw/scsi/
#8 0x0000555557bb916a in esp_pci_io_write (opaque=
#9 0x000055555817ea28 in memory_
#10 0x0000555558176671 in access_
0x55555817e7c0 <memory_
#11 0x00005555581892aa in memory_
#12 0x0000555558024b66 in address_space_stb (as=<optimized out>, addr=<optimized out>, val=<optimized out>, attrs=..., result=0x0) at /home/cwmyung/
#13 0x00007fff9323641c in code_gen_buffer ()
#14 0x0000555557e793bb in cpu_tb_exec (tb_exit=<optimized out>, itb=<optimized out>, cpu=0x62e0000004b4)
at ../accel/
#15 0x0000555557e793bb in cpu_loop_exec_tb (tb_exit=<optimized out>, last_tb=<optimized out>, tb=<optimized out>, cpu=0x62e0000004b4) at ../accel/
#16 0x0000555557e793bb in cpu_exec (cpu=cpu@
#17 0x0000555557f5fc5a in tcg_cpus_exec (cpu=cpu@
#18 0x00005555582260af in mttcg_cpu_thread_fn (arg=arg@
#19 0x0000555558777b05 in qemu_thread_start (args=<optimized out>) at ../util/
#20 0x00007ffff05d26db in start_thread (arg=0x7fff72bf
#21 0x00007ffff02fb71f in clone () at ../sysdeps/
```
To reproduce the assertion failure, please run the QEMU with the following command line.
```
$ ./qemu-system-i386 -m 512 -drive file=./
```
Please let me know if I can provide any further info.
Thank you.
- Cheolwoo, Myung (Seoul National University)
Changed in qemu: | |
status: | Fix Released → Fix Committed |
Changed in qemu: | |
status: | Fix Committed → Fix Released |
Thanks for the test case - looks like the problem occurs because a command hasn't been submitted before initiating a DMA transfer, and TC is set to a value higher than the size of cmdfifo. Can you confirm that the following fix works for you?
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c .0a26ee1dfd 100644 used(&s- >cmdfifo) ;
trace_ esp_do_ dma(cmdlen, len); memory_ read) { free(&s- >cmdfifo) );
s- >dma_memory_ read(s- >dma_opaque, buf, len);
fifo8_ push_all( &s->cmdfifo, buf, len);
index 507ab363bc.
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -573,6 +573,7 @@ static void esp_do_dma(ESPState *s)
cmdlen = fifo8_num_
if (s->dma_
+ len = MIN(len, fifo8_num_
} else {
ATB,
Mark.