Skip to content

Commit f425004

Browse files
committed
igo_nr: validate config blob size before copy
A new configuration blob was copied into the component state as a fixed-size structure without checking the blob was large enough, reading past the allocation for a short blob. Request the blob size and reject one smaller than the configuration structure. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 431e0c3 commit f425004

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

src/audio/igo_nr/igo_nr.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -719,17 +719,32 @@ static void igo_nr_print_config(struct processing_module *mod)
719719
static void igo_nr_set_igo_params(struct processing_module *mod)
720720
{
721721
struct comp_data *cd = module_get_private_data(mod);
722-
struct sof_igo_nr_config *p_config = comp_get_data_blob(cd->model_handler, NULL, NULL);
722+
size_t config_size;
723+
struct sof_igo_nr_config *p_config = comp_get_data_blob(cd->model_handler,
724+
&config_size, NULL);
723725
struct comp_dev *dev = mod->dev;
724726

725727
comp_info(dev, "entry");
726-
igo_nr_check_config_validity(dev, cd);
727728

728-
if (p_config) {
729-
comp_info(dev, "New config detected.");
730-
cd->config = *p_config;
731-
igo_nr_print_config(mod);
729+
if (!p_config)
730+
return;
731+
732+
if (config_size < sizeof(cd->config)) {
733+
comp_err(dev, "New config too small: %zu < %zu",
734+
config_size, sizeof(cd->config));
735+
return;
732736
}
737+
738+
/* validate the incoming blob and only apply it if it passes;
739+
* igo_nr_check_config_validity() re-reads the new blob and logs
740+
* on failure
741+
*/
742+
if (igo_nr_check_config_validity(dev, cd) < 0)
743+
return;
744+
745+
comp_info(dev, "New config detected.");
746+
cd->config = *p_config;
747+
igo_nr_print_config(mod);
733748
}
734749

735750
/* copy and process stream data from source to sink buffers */

0 commit comments

Comments
 (0)