Skip to contentSkip to conversation

scsi: megasas: check 'read_queue_head' index value

PATCH In review P J P 2 participants 2 messages May 25, 2016

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH v2 1/1 scsi: megasas: check 'read_queue_head' index value

From: Prasad J Pandit <[email protected]>

While doing MegaRAID SAS controller command frame lookup, routine 'megasas_lookup_frame' uses 'read_queue_head' value as an index into 'frames[MEGASAS_MAX_FRAMES=2048]' array. Limit its value within array bounds to avoid any OOB access.

---
 hw/scsi/megasas.c | 2 ++
 1 file changed, 2 insertions(+)

Update as per
-> https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg04403.html

hw/scsi/megasas.c +2 -0
index bf642d4..cc66d36 100644
@@ -650,7 +650,9 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd)
     pa_hi = le32_to_cpu(initq->pi_addr_hi);
     s->producer_pa = ((uint64_t) pa_hi << 32) | pa_lo;
     s->reply_queue_head = ldl_le_pci_dma(pcid, s->producer_pa);
+    s->reply_queue_head %= MEGASAS_MAX_FRAMES;
     s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa);
+    s->reply_queue_tail %= MEGASAS_MAX_FRAMES;
     flags = le32_to_cpu(initq->flags);
     if (flags & MFI_QUEUE_FLAG_CONTEXT64) {
         s->flags |= MEGASAS_MASK_USE_QUEUE64;
Signature · 1 line
2.5.5
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · P J P

From: Prasad J Pandit <[email protected]>

While doing MegaRAID SAS controller command frame lookup, routine 'megasas_lookup_frame' uses 'read_queue_head' value as an index into 'frames[MEGASAS_MAX_FRAMES=2048]' array. Limit its value within array bounds to avoid any OOB access.

Alex

Quoted 21 lines
---
  hw/scsi/megasas.c | 2 ++
  1 file changed, 2 insertions(+)

Update as per
-> https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg04403.html

hw/scsi/megasas.c +2 -0
index bf642d4..cc66d36 100644
@@ -650,7 +650,9 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd)
      pa_hi = le32_to_cpu(initq->pi_addr_hi);
      s->producer_pa = ((uint64_t) pa_hi << 32) | pa_lo;
      s->reply_queue_head = ldl_le_pci_dma(pcid, s->producer_pa);
+    s->reply_queue_head %= MEGASAS_MAX_FRAMES;
      s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa);
+    s->reply_queue_tail %= MEGASAS_MAX_FRAMES;
      flags = le32_to_cpu(initq->flags);
      if (flags & MFI_QUEUE_FLAG_CONTEXT64) {
          s->flags |= MEGASAS_MASK_USE_QUEUE64;