Skip to content

Commit 280d2c3

Browse files
committed
mux: ipc4: reject out-of-range source queue ID
set_mux_params() indexed streams[] with the host-supplied bind queue ID without bounds, allowing an OOB write. Validate against MUX_MAX_STREAMS and propagate the error. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent 014c78d commit 280d2c3

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/audio/mux/mux_ipc4.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int build_config(struct processing_module *mod, struct mux_data *cfg)
7878
* set up param then verify param. BTW for IPC3 path, the param is sent by
7979
* host driver.
8080
*/
81-
static void set_mux_params(struct processing_module *mod, struct mux_data *cfg)
81+
static int set_mux_params(struct processing_module *mod, struct mux_data *cfg)
8282
{
8383
struct sof_ipc_stream_params *params = mod->stream_params;
8484
struct comp_data *cd = module_get_private_data(mod);
@@ -117,6 +117,12 @@ static void set_mux_params(struct processing_module *mod, struct mux_data *cfg)
117117

118118
comp_dev_for_each_producer(dev, source) {
119119
j = IPC4_SINK_QUEUE_ID(buf_get_id(source));
120+
/* host-supplied queue ID indexes streams[] */
121+
if (j >= MUX_MAX_STREAMS) {
122+
comp_err(dev, "invalid source queue ID %d (max %d)",
123+
j, MUX_MAX_STREAMS);
124+
return -EINVAL;
125+
}
120126
cd->config.streams[j].pipeline_id = buffer_pipeline_id(source);
121127
if (j == BASE_CFG_QUEUED_ID)
122128
audio_fmt = &cfg->base_cfg.audio_fmt;
@@ -128,6 +134,8 @@ static void set_mux_params(struct processing_module *mod, struct mux_data *cfg)
128134
}
129135

130136
mux_prepare_look_up_table(mod);
137+
138+
return 0;
131139
}
132140

133141
int mux_params(struct processing_module *mod)
@@ -147,7 +155,7 @@ int mux_params(struct processing_module *mod)
147155
if (ret < 0)
148156
return ret;
149157

150-
set_mux_params(mod, cfg);
158+
ret = set_mux_params(mod, cfg);
151159

152160
return ret;
153161
}

0 commit comments

Comments
 (0)