[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/13] hw/sd/sdcard: Assert if accessing an illegal group
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 13/13] hw/sd/sdcard: Assert if accessing an illegal group |
Date: |
Wed, 21 Oct 2020 19:34:50 +0200 |
We can not have more group than 'wpgrps_size'.
Assert if we are accessing a group above this limit.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Alexander Bulekov <alxndr@bu.edu>
Message-Id: <20201015063824.212980-7-f4bug@amsat.org>
---
hw/sd/sd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 4454d168e2f..c3febed2434 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -780,6 +780,7 @@ static void sd_erase(SDState *sd)
sd->csd[14] |= 0x40;
for (i = erase_start; i <= erase_end; i++) {
+ assert(i < sd->wpgrps_size);
if (test_bit(i, sd->wp_groups)) {
sd->card_status |= WP_ERASE_SKIP;
}
@@ -794,6 +795,7 @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr)
wpnum = sd_addr_to_wpnum(addr);
for (i = 0; i < 32; i++, wpnum++, addr += WPGROUP_SIZE) {
+ assert(wpnum < sd->wpgrps_size);
if (addr < sd->size && test_bit(wpnum, sd->wp_groups)) {
ret |= (1 << i);
}
--
2.26.2
- [PULL 03/13] hw/sd/sdhci: Fix DMA Transfer Block Size field, (continued)
- [PULL 03/13] hw/sd/sdhci: Fix DMA Transfer Block Size field, Philippe Mathieu-Daudé, 2020/10/21
- [PULL 04/13] hw/sd/sdhci: Stop multiple transfers when block count is cleared, Philippe Mathieu-Daudé, 2020/10/21
- [PULL 05/13] hw/sd/sdhci: Resume pending DMA transfers on MMIO accesses, Philippe Mathieu-Daudé, 2020/10/21
- [PULL 06/13] hw/sd/sdhci: Let sdhci_update_irq() return if IRQ was delivered, Philippe Mathieu-Daudé, 2020/10/21
- [PULL 07/13] hw/sd/sdhci: Yield if interrupt delivered during multiple transfer, Philippe Mathieu-Daudé, 2020/10/21
- [PULL 08/13] hw/sd/sdcard: Add trace event for ERASE command (CMD38), Philippe Mathieu-Daudé, 2020/10/21
- [PULL 09/13] hw/sd/sdcard: Introduce the INVALID_ADDRESS definition, Philippe Mathieu-Daudé, 2020/10/21
- [PULL 10/13] hw/sd/sdcard: Do not use legal address '0' for INVALID_ADDRESS, Philippe Mathieu-Daudé, 2020/10/21
- [PULL 11/13] hw/sd/sdcard: Reset both start/end addresses on error, Philippe Mathieu-Daudé, 2020/10/21
- [PULL 12/13] hw/sd/sdcard: Do not attempt to erase out of range addresses, Philippe Mathieu-Daudé, 2020/10/21
- [PULL 13/13] hw/sd/sdcard: Assert if accessing an illegal group,
Philippe Mathieu-Daudé <=
- Re: [PULL 00/13] SD/MMC patches for 2020-10-21, Peter Maydell, 2020/10/22