Skip to contentSkip to conversation

scsi: esp: check length before dma read

PATCH Superseded P J P 1 participant 1 message Jun 15, 2016

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH v2 1/1 scsi: esp: check length before dma read

From: Prasad J Pandit <[email protected]>

While doing DMA read into ESP command buffer 's->cmdbuf', the length parameter could exceed the buffer size. Add check to avoid OOB access.

---
 hw/scsi/esp.c | 3 +++
 1 file changed, 3 insertions(+)

Update:
- corrected Li Qiang's email id above.

hw/scsi/esp.c +3 -0
index 4b94bbc..dfea571 100644
@@ -249,6 +249,9 @@ static void esp_do_dma(ESPState *s)
     len = s->dma_left;
     if (s->do_cmd) {
         trace_esp_do_dma(s->cmdlen, len);
+        if (s->cmdlen + len >= sizeof(s->cmdbuf)) {
+            return;
+        }
         s->dma_memory_read(s->dma_opaque, &s->cmdbuf[s->cmdlen], len);
         s->ti_size = 0;
         s->cmdlen = 0;
Signature · 1 line
2.5.5