Skip to content

Commit 9f39959

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 9f39959

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/audio/module_adapter/module_adapter_ipc4.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,22 @@ 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+
/*
270+
* *data_offset_size is host-supplied (the IPC4 data_off_size
271+
* field) and both operands are unsigned, so reject an offset
272+
* past the config size to avoid the subtraction underflowing
273+
* into a huge fragment_size passed to get_configuration().
274+
*/
275+
if (*data_offset_size > md->cfg.size) {
276+
comp_err(dev, "invalid data_offset_size %u > cfg size %zu",
277+
*data_offset_size, md->cfg.size);
278+
return -EINVAL;
279+
}
269280
fragment_size = md->cfg.size - *data_offset_size;
281+
}
270282
}
271283

272284
if (interface->get_configuration)

0 commit comments

Comments
 (0)