Skip to content

Commit 8112cf2

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 8112cf2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/audio/copier/copier.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ __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+
* cfg_total_size is at least sizeof(*copier), so this also rejects an
154+
* empty (md->cfg.size == 0) or otherwise too-small init payload.
155+
*/
156+
if (cfg_total_size > md->cfg.size) {
157+
comp_err(dev, "copier_init(): cfg size %zu exceeds init payload %zu",
158+
cfg_total_size, md->cfg.size);
159+
return -EINVAL;
160+
}
161+
150162
cd = mod_zalloc(mod, sizeof(*cd) + gtw_cfg_var_size);
151163
if (!cd)
152164
return -ENOMEM;

0 commit comments

Comments
 (0)