Skip to content

Commit 9105ea4

Browse files
committed
smart_amp: bound get-config copy by config struct size
The config read-back used the stored config size as the memcpy source length from a fixed-size struct; a host-set oversized size read adjacent heap. Bound the length by the struct size as well as the destination. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 23126a2 commit 9105ea4

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/audio/smart_amp/smart_amp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,11 @@ static int smart_amp_get_config(struct processing_module *mod,
289289
comp_dbg(dev, "actual blob size = %zu, expected blob size = %zu",
290290
bs, sizeof(struct sof_smart_amp_config));
291291

292-
if (bs == 0 || bs > size)
292+
/* bs is the host-set config.size and is used as the memcpy source
293+
* length from the fixed-size sad->config, so bound it by the struct
294+
* size as well as the destination buffer
295+
*/
296+
if (bs == 0 || bs > size || bs > sizeof(struct sof_smart_amp_config))
293297
return -EINVAL;
294298

295299
ret = memcpy_s(cdata->data->data, size, &sad->config, bs);

0 commit comments

Comments
 (0)