Skip to content

Commit 902eb7c

Browse files
committed
rtnr: reject out-of-range control switch element counts
The SWITCH control get and set handlers looped over a host-supplied element count while reading/writing the control channel array, which could run past the IPC payload. Reject counts larger than the maximum channel count in both handlers before the loop. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 3f7738d commit 902eb7c

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/audio/rtnr/rtnr.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@ static int rtnr_get_config(struct processing_module *mod,
454454
return rtnr_get_bin_data(mod, cdata, fragment_size);
455455

456456
case SOF_CTRL_CMD_SWITCH:
457+
if (cdata->num_elems > SOF_IPC_MAX_CHANNELS) {
458+
comp_err(dev, "num_elems %u > max %u",
459+
cdata->num_elems, SOF_IPC_MAX_CHANNELS);
460+
return -EINVAL;
461+
}
457462
for (j = 0; j < cdata->num_elems; j++) {
458463
cdata->chanv[j].channel = j;
459464
cdata->chanv[j].value = cd->process_enable;
@@ -560,6 +565,12 @@ static int32_t rtnr_set_value(struct processing_module *mod, void *ctl_data)
560565
uint32_t val = 0;
561566
int32_t j;
562567

568+
if (cdata->num_elems > SOF_IPC_MAX_CHANNELS) {
569+
comp_err(dev, "num_elems %u > max %u",
570+
cdata->num_elems, SOF_IPC_MAX_CHANNELS);
571+
return -EINVAL;
572+
}
573+
563574
for (j = 0; j < cdata->num_elems; j++) {
564575
val |= cdata->chanv[j].value;
565576
comp_dbg(dev, "value = %u", val);

0 commit comments

Comments
 (0)