From: P J P <ppandit@redhat.com>
To: Qemu Developers <qemu-devel@nongnu.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>, Li Qiang <liqiang6-s@360.cn>,
Hannes Reinecke <hare@suse.de>, Alexander Graf <agraf@suse.de>,
Prasad J Pandit <pjp@fedoraproject.org>
Subject: [Qemu-devel] [PATCH 3/3] scsi: megasas: check 'read_queue_head' index value
Date: Wed, 25 May 2016 16:01:31 +0530 [thread overview]
Message-ID: <1464172291-2856-4-git-send-email-ppandit@redhat.com> (raw)
In-Reply-To: <1464172291-2856-1-git-send-email-ppandit@redhat.com>
From: Prasad J Pandit <pjp@fedoraproject.org>
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.
Reported-by: Li Qiang <liqiang6-s@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
hw/scsi/megasas.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 7c08932..76d57f9 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -649,8 +649,10 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd)
pa_lo = le32_to_cpu(initq->pi_addr_lo);
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_tail = ldl_le_pci_dma(pcid, s->consumer_pa);
+ s->reply_queue_head = \
+ ldl_le_pci_dma(pcid, s->producer_pa) % MEGASAS_MAX_FRAMES;
+ s->reply_queue_tail = \
+ ldl_le_pci_dma(pcid, s->consumer_pa) % MEGASAS_MAX_FRAMES;
flags = le32_to_cpu(initq->flags);
if (flags & MFI_QUEUE_FLAG_CONTEXT64) {
s->flags |= MEGASAS_MASK_USE_QUEUE64;
--
2.5.5
next prev parent reply other threads:[~2016-05-25 10:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-25 10:31 [Qemu-devel] [PATCH 0/3] Qemu: scsi: megasas: various OOB r/w access checks P J P
2016-05-25 10:31 ` [Qemu-devel] [PATCH 1/3] scsi: megasas: use appropriate property buffer size P J P
2016-05-25 11:06 ` Alexander Graf
2016-05-25 11:51 ` P J P
2016-05-25 11:53 ` Alexander Graf
2016-05-25 12:15 ` P J P
2016-05-25 12:30 ` Alexander Graf
2016-05-25 10:31 ` [Qemu-devel] [PATCH 2/3] scsi: megasas: initialise local configuration data buffer P J P
2016-05-25 11:15 ` Alexander Graf
2016-05-25 10:31 ` P J P [this message]
2016-05-25 11:20 ` [Qemu-devel] [PATCH 3/3] scsi: megasas: check 'read_queue_head' index value Alexander Graf
2016-05-25 13:21 ` Hannes Reinecke
2016-05-25 12:00 ` [Qemu-devel] [PATCH 0/3] Qemu: scsi: megasas: various OOB r/w access checks Paolo Bonzini
2016-05-25 12:08 ` Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1464172291-2856-4-git-send-email-ppandit@redhat.com \
--to=ppandit@redhat.com \
--cc=agraf@suse.de \
--cc=hare@suse.de \
--cc=liqiang6-s@360.cn \
--cc=pbonzini@redhat.com \
--cc=pjp@fedoraproject.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).