Skip to content

Commit 133784c

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 f8eb9d8 commit 133784c

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/audio/igo_nr/igo_nr.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,13 +720,26 @@ static void igo_nr_print_config(struct processing_module *mod)
720720
static void igo_nr_set_igo_params(struct processing_module *mod)
721721
{
722722
struct comp_data *cd = module_get_private_data(mod);
723-
struct sof_igo_nr_config *p_config = comp_get_data_blob(cd->model_handler, NULL, NULL);
723+
size_t config_size = 0;
724+
struct sof_igo_nr_config *p_config = comp_get_data_blob(cd->model_handler,
725+
&config_size, NULL);
724726
struct comp_dev *dev = mod->dev;
725727

726728
comp_info(dev, "entry");
727-
igo_nr_check_config_validity(dev, cd);
728729

729730
if (p_config) {
731+
if (config_size < sizeof(cd->config)) {
732+
comp_err(dev, "New config too small: %zu < %zu",
733+
config_size, sizeof(cd->config));
734+
return;
735+
}
736+
/* validate the incoming blob and only apply it if it passes;
737+
* igo_nr_check_config_validity() re-reads the new blob
738+
*/
739+
if (igo_nr_check_config_validity(dev, cd) < 0) {
740+
comp_err(dev, "New config failed validation, not applied");
741+
return;
742+
}
730743
comp_info(dev, "New config detected.");
731744
cd->config = *p_config;
732745
igo_nr_print_config(mod);

0 commit comments

Comments
 (0)