[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/24] esp: restrict non-DMA transfer length to that of available
From: |
Paolo Bonzini |
Subject: |
[PULL 09/24] esp: restrict non-DMA transfer length to that of available data |
Date: |
Tue, 3 Oct 2023 10:30:26 +0200 |
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
In the case where a SCSI layer transfer is incorrectly terminated, it is
possible for a TI command to cause a SCSI buffer overflow due to the
expected transfer data length being less than the available data in the
FIFO. When this occurs the unsigned async_len variable underflows and
becomes a large offset which writes past the end of the allocated SCSI
buffer.
Restrict the non-DMA transfer length to be the smallest of the expected
transfer length and the available FIFO data to ensure that it is no longer
possible for the SCSI buffer overflow to occur.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1810
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20230913204410.65650-3-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/scsi/esp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 4218a6a9605..9b11d8c5738 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -759,7 +759,8 @@ static void esp_do_nodma(ESPState *s)
}
if (to_device) {
- len = MIN(fifo8_num_used(&s->fifo), ESP_FIFO_SZ);
+ len = MIN(s->async_len, ESP_FIFO_SZ);
+ len = MIN(len, fifo8_num_used(&s->fifo));
esp_fifo_pop_buf(&s->fifo, s->async_buf, len);
s->async_buf += len;
s->async_len -= len;
--
2.41.0
- [PULL 16/24] audio: commonize voice initialization, (continued)
- [PULL 16/24] audio: commonize voice initialization, Paolo Bonzini, 2023/10/03
- [PULL 19/24] Introduce machine property "audiodev", Paolo Bonzini, 2023/10/03
- [PULL 17/24] audio: simplify flow in audio_init, Paolo Bonzini, 2023/10/03
- [PULL 04/24] pc: remove short_root_bus property, Paolo Bonzini, 2023/10/03
- [PULL 22/24] vt82c686 machines: Support machine-default audiodev with fallback, Paolo Bonzini, 2023/10/03
- [PULL 20/24] hw/arm: Support machine-default audiodev with fallback, Paolo Bonzini, 2023/10/03
- [PULL 13/24] audio: Require AudioState in AUD_add_capture, Paolo Bonzini, 2023/10/03
- [PULL 14/24] audio: allow returning an error from the driver init, Paolo Bonzini, 2023/10/03
- [PULL 18/24] audio: remove QEMU_AUDIO_* and -audio-help support, Paolo Bonzini, 2023/10/03
- [PULL 24/24] audio: forbid default audiodev backend with -nodefaults, Paolo Bonzini, 2023/10/03
- [PULL 09/24] esp: restrict non-DMA transfer length to that of available data,
Paolo Bonzini <=
- [PULL 23/24] audio: propagate Error * out of audio_init, Paolo Bonzini, 2023/10/03
- Re: [PULL 00/24] Audio, build system, misc fixes for 2023-10-03, Stefan Hajnoczi, 2023/10/03
- Re: [PULL 00/24] Audio, build system, misc fixes for 2023-10-03, Michael Tokarev, 2023/10/03