carlwgeorge / rpms / qemu

Forked from rpms/qemu a year ago
Clone
eaa6ce4
From: Prasad J Pandit <pjp@fedoraproject.org>
eaa6ce4
Date: Tue, 7 Feb 2017 18:29:59 +0000
eaa6ce4
Subject: [PATCH] sd: sdhci: check data length during dma_memory_read
eaa6ce4
eaa6ce4
While doing multi block SDMA transfer in routine
eaa6ce4
'sdhci_sdma_transfer_multi_blocks', the 's->fifo_buffer' starting
eaa6ce4
index 'begin' and data length 's->data_count' could end up to be same.
eaa6ce4
This could lead to an OOB access issue. Correct transfer data length
eaa6ce4
to avoid it.
eaa6ce4
eaa6ce4
Cc: qemu-stable@nongnu.org
eaa6ce4
Reported-by: Jiang Xin <jiangxin1@huawei.com>
eaa6ce4
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
eaa6ce4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
eaa6ce4
Message-id: 20170130064736.9236-1-ppandit@redhat.com
eaa6ce4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
eaa6ce4
(cherry picked from commit 42922105beb14c2fc58185ea022b9f72fb5465e9)
eaa6ce4
---
eaa6ce4
 hw/sd/sdhci.c | 2 +-
eaa6ce4
 1 file changed, 1 insertion(+), 1 deletion(-)
eaa6ce4
eaa6ce4
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
3d039dc
index 01fbf228be..5bd5ab6319 100644
eaa6ce4
--- a/hw/sd/sdhci.c
eaa6ce4
+++ b/hw/sd/sdhci.c
eaa6ce4
@@ -536,7 +536,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
eaa6ce4
                 boundary_count -= block_size - begin;
eaa6ce4
             }
eaa6ce4
             dma_memory_read(&address_space_memory, s->sdmasysad,
eaa6ce4
-                            &s->fifo_buffer[begin], s->data_count);
eaa6ce4
+                            &s->fifo_buffer[begin], s->data_count - begin);
eaa6ce4
             s->sdmasysad += s->data_count - begin;
eaa6ce4
             if (s->data_count == block_size) {
eaa6ce4
                 for (n = 0; n < block_size; n++) {