Skip to content

Commit 950e2b1

Browse files
committed
copier: validate gateway count before computing config size
The multi-gateway count from the gateway config was used to compute sizes and walk the mapping array before being bounded. Reject a count above the supported maximum before any arithmetic. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 8112cf2 commit 950e2b1

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/audio/copier/copier_dai.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ static int copier_alh_assign_dai_index(struct comp_dev *dev,
8888
switch (dai->type) {
8989
case SOF_DAI_INTEL_HDA:
9090
/* We use DAI_INTEL_HDA for ACE 2.0 platforms */
91+
/*
92+
* alh_cfg.count is host-controlled and scales the config size
93+
* and mapping[] walk below; bound it before any arithmetic so a
94+
* crafted blob cannot read past the gateway config.
95+
*/
96+
if (alh_blob->alh_cfg.count > IPC4_ALH_MAX_NUMBER_OF_GTW) {
97+
comp_err(mod->dev, "Invalid ALH count: %u",
98+
alh_blob->alh_cfg.count);
99+
return -EINVAL;
100+
}
91101
alh_cfg_size = get_alh_config_size(alh_blob);
92102
dma_config = (uint8_t *)gtw_cfg_data + alh_cfg_size;
93103
dma_config_length = (cd->config.gtw_cfg.config_length << 2) - alh_cfg_size;

0 commit comments

Comments
 (0)