|
|
cf91b1 |
From: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
cf91b1 |
Date: Wed, 25 May 2016 17:55:10 +0530
|
|
|
cf91b1 |
Subject: [PATCH] scsi: megasas: check 'read_queue_head' index value
|
|
|
cf91b1 |
|
|
|
cf91b1 |
While doing MegaRAID SAS controller command frame lookup, routine
|
|
|
cf91b1 |
'megasas_lookup_frame' uses 'read_queue_head' value as an index
|
|
|
cf91b1 |
into 'frames[MEGASAS_MAX_FRAMES=2048]' array. Limit its value
|
|
|
cf91b1 |
within array bounds to avoid any OOB access.
|
|
|
cf91b1 |
|
|
|
cf91b1 |
Reported-by: Li Qiang <liqiang6-s@360.cn>
|
|
|
cf91b1 |
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
cf91b1 |
Message-Id: <1464179110-18593-1-git-send-email-ppandit@redhat.com>
|
|
|
cf91b1 |
Reviewed-by: Alexander Graf <agraf@suse.de>
|
|
|
cf91b1 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
cf91b1 |
(cherry picked from commit b60bdd1f1ee1616b7a9aeeffb4088e1ce2710fb2)
|
|
|
cf91b1 |
---
|
|
|
cf91b1 |
hw/scsi/megasas.c | 2 ++
|
|
|
cf91b1 |
1 file changed, 2 insertions(+)
|
|
|
cf91b1 |
|
|
|
cf91b1 |
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
|
|
|
cf91b1 |
index bf642d4..cc66d36 100644
|
|
|
cf91b1 |
--- a/hw/scsi/megasas.c
|
|
|
cf91b1 |
+++ b/hw/scsi/megasas.c
|
|
|
cf91b1 |
@@ -650,7 +650,9 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd)
|
|
|
cf91b1 |
pa_hi = le32_to_cpu(initq->pi_addr_hi);
|
|
|
cf91b1 |
s->producer_pa = ((uint64_t) pa_hi << 32) | pa_lo;
|
|
|
cf91b1 |
s->reply_queue_head = ldl_le_pci_dma(pcid, s->producer_pa);
|
|
|
cf91b1 |
+ s->reply_queue_head %= MEGASAS_MAX_FRAMES;
|
|
|
cf91b1 |
s->reply_queue_tail = ldl_le_pci_dma(pcid, s->consumer_pa);
|
|
|
cf91b1 |
+ s->reply_queue_tail %= MEGASAS_MAX_FRAMES;
|
|
|
cf91b1 |
flags = le32_to_cpu(initq->flags);
|
|
|
cf91b1 |
if (flags & MFI_QUEUE_FLAG_CONTEXT64) {
|
|
|
cf91b1 |
s->flags |= MEGASAS_MASK_USE_QUEUE64;
|