diff options
| author | Ian Roberts <[email protected]> | 2024-03-25 22:22:37 -0400 |
|---|---|---|
| committer | Jaehoon Chung <[email protected]> | 2024-04-26 15:31:00 +0900 |
| commit | 5f0714496869b95e57a8b72192089e7df18c94cf (patch) | |
| tree | 0a8072fabf682c49393be7664258d6e5b2e4aad4 /include/linux | |
| parent | 74755c1fed1b09526b0993c729fe3ae909752fbd (diff) | |
mmc: sdhci: Fix potential ADMA descriptor table overflow
Change ADMA_TABLE_NO_ENTRIES to round the division up to fully
contain CONFIG_SYS_MMC_MAX_BLK_COUNT, fixing potential buffer overflow
of the ADMA descriptor table.
sdhci_prepare_adma_table() expecitily states it does _not_ check for
overflow as the descriptor table size is dependent on
CONFIG_SYS_MMC_MAX_BLK_COUNT. However, the ADMA_TABLE_NO_ENTRIES
calculation does not round up the divison, so with the current u-boot
defaults:
max_mmc_transfer = (CONFIG_SYS_MMC_MAX_BLK_COUNT * MMC_MAX_BLOCK_LEN) =
65535 * 512 = 33553920 bytes.
ADMA_TABLE_NO_ENTRIES = max_mmc_transfer / ADMA_MAX_LEN =
33553920 / 65532, which does not divide cleanly.
actual_max_transfer = ADMA_TABLE_NO_ENTRIES * ADMA_MAX_LEN = 512 *
65532 = 33552384, which is smaller than max_mmc_transfer.
This can cause sdhci_prepare_adma_table() to write one extra
descriptor, overflowing the table when a transaction larger than
actual_max_transfer is issued.
Co-developed-by: Nathan Barrett-Morrison <[email protected]>
Signed-off-by: Nathan Barrett-Morrison <[email protected]>
Signed-off-by: Greg Malysa <[email protected]>
Signed-off-by: Ian Roberts <[email protected]>
Reviewed-by: Jaehoon Chung <[email protected]>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions
