Skip to content

Commit e75b60f

Browse files
committed
copier: bound gateway config length to init payload size
The gateway configuration length from the init payload was multiplied and used as a copy length from the mailbox without checking it against the actual payload size. Reject a configuration that would read past the init payload. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 3f7738d commit e75b60f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/audio/copier/copier.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ __cold static int copier_init(struct processing_module *mod)
147147
cfg_total_size += gtw_cfg_var_size;
148148
}
149149

150+
/*
151+
* gtw_cfg.config_length is host-controlled; make sure the resulting
152+
* copy length does not read past the init payload in the mailbox.
153+
*/
154+
if (md->cfg.size && cfg_total_size > md->cfg.size) {
155+
comp_err(dev, "copier_init(): cfg size %zu exceeds init payload %zu",
156+
cfg_total_size, md->cfg.size);
157+
return -EINVAL;
158+
}
159+
150160
cd = mod_zalloc(mod, sizeof(*cd) + gtw_cfg_var_size);
151161
if (!cd)
152162
return -ENOMEM;

0 commit comments

Comments
 (0)