Skip to content

Commit 52d6b34

Browse files
committed
ipc4: helper: validate host device_count before indexing channel map
dma_cfg->channel_map.device_count comes from a host supplied gateway config blob and was used directly to bound the loop indexing the fixed channel_map.map[GTW_DMA_DEVICE_MAX_COUNT] array, allowing an out-of-bounds read. Reject counts above the ABI maximum with IPC4_INVALID_REQUEST. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent 0f9fa75 commit 52d6b34

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/ipc/ipc4/helper.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,12 +1313,20 @@ int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buff
13131313
if (!dma_cfg)
13141314
continue;
13151315

1316+
uint32_t device_count = dma_cfg->channel_map.device_count;
1317+
1318+
if (device_count > GTW_DMA_DEVICE_MAX_COUNT) {
1319+
tr_err(&ipc_tr, "device_count %u exceeds max %u",
1320+
device_count, GTW_DMA_DEVICE_MAX_COUNT);
1321+
return IPC4_INVALID_REQUEST;
1322+
}
1323+
13161324
/* To be able to retrieve proper DMA config we need to check if
13171325
* device_id value (which is alh_id) is equal to device_address.
13181326
* They both contain SNDW master id and PDI. If they match then
13191327
* proper config is found.
13201328
*/
1321-
for (uint32_t i = 0; i < dma_cfg->channel_map.device_count; i++) {
1329+
for (uint32_t i = 0; i < device_count; i++) {
13221330
if (dma_cfg->channel_map.map[i].device_address == device_id) {
13231331
dai->host_dma_config[dma_cfg_idx] = dma_cfg;
13241332
return IPC4_SUCCESS;

0 commit comments

Comments
 (0)