fix(sdmmc): Validate DMA buffer address range

Closes https://github.com/espressif/esp-idf/issues/18714
This commit is contained in:
Adam Múdry
2026-07-28 15:36:44 +02:00
parent 0bae8d1e27
commit a89ca4caf6
9 changed files with 106 additions and 23 deletions
@@ -0,0 +1,22 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct sd_host_sdmmc_slot_t sd_host_sdmmc_slot_t;
bool sd_host_check_buffer_alignment(sd_host_sdmmc_slot_t *slot, const void *buf, size_t size);
#ifdef __cplusplus
}
#endif
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -14,6 +14,7 @@
#include "esp_check.h"
#include "esp_pm.h"
#include "esp_cache.h"
#include "esp_private/sd_host_buffer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "driver/sd_host_sdmmc.h"
@@ -95,7 +96,6 @@ typedef struct {
size_t desc_remaining;
} sd_host_sdmmc_trans_state_t;
typedef struct sd_host_sdmmc_slot_t sd_host_sdmmc_slot_t;
typedef struct sd_host_sdmmc_ctlr_t sd_host_sdmmc_ctlr_t;
/**
@@ -333,19 +333,6 @@ void sd_host_dma_prepare(sd_host_sdmmc_slot_t *slot, void* data_ptr, size_t data
/*---------------------------------------------------------------
Info APIs
---------------------------------------------------------------*/
/**
* @brief Check SD buffer alignment
*
* @param[in] slot SD Host slot handle
* @param[in] buf Buffer pointer
* @param[in] size Buffer size
*
* @return
* - True: alignment requirement is satisfied
* - False: alignment requirement is not satisfied
*/
bool sd_host_check_buffer_alignment(sd_host_sdmmc_slot_t *slot, const void *buf, size_t size);
/**
* @brief Get SD Host slot real frequency
*