Skip to content

Commit 8aeb445

Browse files
abonislawskilgirdwood
authored andcommitted
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 382ea2f commit 8aeb445

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
@@ -1312,12 +1312,20 @@ int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buff
13121312
if (!dma_cfg)
13131313
continue;
13141314

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

0 commit comments

Comments
 (0)