Skip to content

Commit 77fd9ef

Browse files
committed
multiband_drc: validate config blob covers all bands
Setup read a base config struct and per-band coefficients from the blob without a size check, over-reading for a short blob. Require the blob to cover the base struct and num_bands band entries. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent acd2564 commit 77fd9ef

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/audio/multiband_drc/multiband_drc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,14 @@ static int multiband_drc_prepare(struct processing_module *mod,
369369
comp_dbg(dev, "source_format=%d, sink_format=%d",
370370
cd->source_format, cd->source_format);
371371
cd->config = comp_get_data_blob(cd->model_handler, &data_size, NULL);
372-
if (cd->config && data_size > 0) {
372+
/* the blob holds a base struct followed by num_bands variable-length
373+
* band coefficients; require the base struct first, then the full
374+
* per-band payload, so setup cannot read past the blob
375+
*/
376+
if (cd->config && data_size >= sizeof(struct sof_multiband_drc_config) &&
377+
cd->config->num_bands <= SOF_MULTIBAND_DRC_MAX_BANDS &&
378+
data_size >= sizeof(struct sof_multiband_drc_config) +
379+
(size_t)cd->config->num_bands * sizeof(struct sof_drc_params)) {
373380
ret = multiband_drc_setup(mod, channels, rate);
374381
if (ret < 0) {
375382
comp_err(dev, "error: multiband_drc_setup failed.");

0 commit comments

Comments
 (0)