Skip to content

Commit 8f32619

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 c22187c commit 8f32619

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
@@ -80,7 +80,7 @@ static int build_config(struct processing_module *mod, struct mux_data *cfg)
8080
* set up param then verify param. BTW for IPC3 path, the param is sent by
8181
* host driver.
8282
*/
83-
static void set_mux_params(struct processing_module *mod, struct mux_data *cfg)
83+
static int set_mux_params(struct processing_module *mod, struct mux_data *cfg)
8484
{
8585
struct sof_ipc_stream_params *params = mod->stream_params;
8686
struct comp_data *cd = module_get_private_data(mod);
@@ -119,6 +119,12 @@ static void set_mux_params(struct processing_module *mod, struct mux_data *cfg)
119119

120120
comp_dev_for_each_producer(dev, source) {
121121
j = IPC4_SINK_QUEUE_ID(buf_get_id(source));
122+
/* host-supplied queue ID indexes streams[] */
123+
if (j >= MUX_MAX_STREAMS) {
124+
comp_err(dev, "invalid source queue ID %d (valid range 0..%d)",
125+
j, MUX_MAX_STREAMS - 1);
126+
return -EINVAL;
127+
}
122128
cd->config.streams[j].pipeline_id = buffer_pipeline_id(source);
123129
if (j == BASE_CFG_QUEUED_ID)
124130
audio_fmt = &cfg->base_cfg.audio_fmt;
@@ -130,6 +136,8 @@ static void set_mux_params(struct processing_module *mod, struct mux_data *cfg)
130136
}
131137

132138
mux_prepare_look_up_table(mod);
139+
140+
return 0;
133141
}
134142

135143
int mux_params(struct processing_module *mod)
@@ -149,7 +157,7 @@ int mux_params(struct processing_module *mod)
149157
if (ret < 0)
150158
return ret;
151159

152-
set_mux_params(mod, cfg);
160+
ret = set_mux_params(mod, cfg);
153161

154162
return ret;
155163
}

0 commit comments

Comments
 (0)