[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/6] esp: don't overflow cmdfifo if TC is larger than the cmdf
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v2 2/6] esp: don't overflow cmdfifo if TC is larger than the cmdfifo size |
Date: |
Wed, 17 Mar 2021 23:02:19 +0000 |
If a guest transfers the message out/command phase data using DMA with a TC
that is larger than the cmdfifo size then the cmdfifo overflows triggering
an assert. Limit the size of the transfer to the free space available in
cmdfifo.
Buglink: https://bugs.launchpad.net/qemu/+bug/1919036
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Alexander Bulekov <alxndr@bu.edu>
---
hw/scsi/esp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 5d3f1ccbc8..bbcbfa4a91 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -579,6 +579,7 @@ static void esp_do_dma(ESPState *s)
cmdlen = fifo8_num_used(&s->cmdfifo);
trace_esp_do_dma(cmdlen, len);
if (s->dma_memory_read) {
+ len = MIN(len, fifo8_num_free(&s->cmdfifo));
s->dma_memory_read(s->dma_opaque, buf, len);
fifo8_push_all(&s->cmdfifo, buf, len);
} else {
--
2.20.1
- [PATCH v2 0/6] esp: fix asserts/segfaults discovered by fuzzer, Mark Cave-Ayland, 2021/03/17
- [PATCH v2 1/6] esp: don't underflow cmdfifo if no message out/command data is present, Mark Cave-Ayland, 2021/03/17
- [PATCH v2 2/6] esp: don't overflow cmdfifo if TC is larger than the cmdfifo size,
Mark Cave-Ayland <=
- [PATCH v2 3/6] esp: ensure cmdfifo is not empty and current_dev is non-NULL, Mark Cave-Ayland, 2021/03/17
- [PATCH v2 4/6] esp: don't underflow fifo when writing to the device, Mark Cave-Ayland, 2021/03/17
- [PATCH v2 5/6] esp: always check current_req is not NULL before use in DMA callbacks, Mark Cave-Ayland, 2021/03/17
- [PATCH v2 6/6] tests/qtest: add tests for am53c974 device, Mark Cave-Ayland, 2021/03/17
- Re: [PATCH v2 0/6] esp: fix asserts/segfaults discovered by fuzzer, Paolo Bonzini, 2021/03/18