Skip to content

Commit d31bf48

Browse files
committed
audio: module_adapter_ipc4: add range check to module_get_large_config()
In a multi-block get case, if the host sends data_off_size > md->cfg.size, the calculation of the last fragment size is incorrect if a sufficiently large value is passed. Add validation to catch this case and return an error data_off_size is too large. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 3f7738d commit d31bf48

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/audio/module_adapter/module_adapter_ipc4.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,16 @@ int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_
263263
else
264264
fragment_size = SOF_IPC_MSG_MAX_SIZE;
265265
} else {
266-
if (!last_block)
266+
if (!last_block) {
267267
fragment_size = SOF_IPC_MSG_MAX_SIZE;
268-
else
268+
} else {
269+
if (*data_offset_size > md->cfg.size) {
270+
comp_err(dev, "invalid data_offset_size %u > cfg size %zu",
271+
*data_offset_size, md->cfg.size);
272+
return -EINVAL;
273+
}
269274
fragment_size = md->cfg.size - *data_offset_size;
275+
}
270276
}
271277

272278
if (interface->get_configuration)

0 commit comments

Comments
 (0)