aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2021-04-07 20:57:58 +0100
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2021-04-12 22:35:53 +0100
commit0ebb5fd80589835153a0c2baa1b8cc7a04e67a93 (patch)
tree3aa508aa2e1a85588b25a5e81291ab4e6beaead2
parentfbc6510e3379fa8f8370bf71198f0ce733bf07f9 (diff)
downloadqemu-0ebb5fd80589835153a0c2baa1b8cc7a04e67a93.zip
qemu-0ebb5fd80589835153a0c2baa1b8cc7a04e67a93.tar.gz
qemu-0ebb5fd80589835153a0c2baa1b8cc7a04e67a93.tar.bz2
esp: don't overflow cmdfifo if TC is larger than the cmdfifo size
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> Message-Id: <20210407195801.685-10-mark.cave-ayland@ilande.co.uk>
-rw-r--r--hw/scsi/esp.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 9d3fdb4..a26a109 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -578,6 +578,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 {