sd: sdhci: check data length during dma_memory_read
PATCH 1/1 sd: sdhci: check data length during dma_memory_read
From: Prasad J Pandit <[email protected]>
While doing multi block SDMA transfer in routine 'sdhci_sdma_transfer_multi_blocks', the 's->fifo_buffer' starting index 'begin' and data length 's->data_count' could end up to be same. This could lead to an OOB access issue. Correct transfer data length to avoid it.
--- hw/sd/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sdhci.c +1 -1
@@ -536,7 +536,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) boundary_count -= block_size - begin; }dma_memory_read (&address_space_memory, s->sdmasysad, - &s->fifo_buffer[begin], s->data_count); + &s->fifo_buffer[begin], s->data_count - begin); s->sdmasysad += s->data_count - begin;if (s->data_count == block_size) {for (n =0 ; n < block_size; n++) {
Signature · 1 line
2.9.3
Quoted 19 lines · P J P
From: Prasad J Pandit <[email protected]>
While doing multi block SDMA transfer in routine '
sdhci_sdma_transfer_multi_blocks', the 's->fifo_buffer' starting index 'begin' and data length 's->data_count' could end up to be same. This could lead to an OOB access issue. Correct transfer data length to avoid it.Reported-by Jiang Xin <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>--- hw/sd/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/sd/sdhci.c +0
-0
hw/sd/sdhci.c static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) · line 542
Quoted 8 lines
hw/sd/sdhci.c +1
-1@@ -536,7 +536,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) boundary_count -= block_size - begin; }dma_memory_read (&address_space_memory, s->sdmasysad, - &s->fifo_buffer[begin], s->data_count); + &s->fifo_buffer[begin], s->data_count - begin); s->sdmasysad += s->data_count - begin;if (s->data_count == block_size) {for (n =0 ; n < block_size; n++) {
thanks
-- PMM
Peter Maydell
AppliedQuoted 15 lines · Peter Maydell
Quoted 14 lines · P J P
From: Prasad J Pandit <[email protected]>
While doing multi block SDMA transfer in routine '
sdhci_sdma_transfer_multi_blocks', the 's->fifo_buffer' starting index 'begin' and data length 's->data_count' could end up to be same. This could lead to an OOB access issue. Correct transfer data length to avoid it.Reported-by Jiang Xin <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>--- hw/sd/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
hw/sd/sdhci.c static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) · line 542
Quoted 13 lines
hw/sd/sdhci.c +1
-1@@ -536,7 +536,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) boundary_count -= block_size - begin; }dma_memory_read (&address_space_memory, s->sdmasysad, - &s->fifo_buffer[begin], s->data_count); + &s->fifo_buffer[begin], s->data_count - begin); s->sdmasysad += s->data_count - begin;if (s->data_count == block_size) {for (n =0 ; n < block_size; n++) {Reviewed-by Peter Maydell <[email protected]>
Applied to target-arm.next, thanks.
-- PMM