Skip to content

Commit 1fed0c2

Browse files
committed
audio: cadence: validate TLV param size before applying config
Bound each host-supplied module_param against the bytes remaining to avoid an OOB read or a stalled loop. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent e7b9dbe commit 1fed0c2

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/audio/module_adapter/module/cadence.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,24 @@ int cadence_codec_apply_params(struct processing_module *mod, int size, void *da
358358
*/
359359
while (size > 0) {
360360
param = data;
361+
362+
/* Host-supplied blob: the header must fit before param->size
363+
* can be read.
364+
*/
365+
if (size < (int)sizeof(*param)) {
366+
comp_err(dev, "param header truncated, %d bytes left", size);
367+
return -EINVAL;
368+
}
369+
370+
/* param->size covers the whole record and must fit in the
371+
* remaining bytes.
372+
*/
373+
if (param->size <= sizeof(*param) || param->size > (uint32_t)size) {
374+
comp_err(dev, "invalid param size %u, %d bytes left",
375+
param->size, size);
376+
return -EINVAL;
377+
}
378+
361379
comp_dbg(dev, "cadence_codec_apply_config() applying param %d value %d",
362380
param->id, param->data[0]);
363381

0 commit comments

Comments
 (0)