Skip to content

Commit 4ef2a35

Browse files
ujfalusibardliao
authored andcommitted
ASoC: SOF: ipc3-control: Validate size in snd_sof_update_control
In snd_sof_update_control(), firmware-provided cdata->num_elems is checked against local_cdata->data->size but never against the actual allocation size. If local_cdata->data->size was previously set to an inconsistent value, the memcpy could write past the allocated buffer. Add a bounds check to ensure num_elems fits within the available space in the ipc_control_data allocation before copying. Fixes: 10f461d ("ASoC: SOF: Add IPC3 topology control ops") Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent e7488f0 commit 4ef2a35

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

sound/soc/sof/ipc3-control.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,15 @@ static void snd_sof_update_control(struct snd_sof_control *scontrol,
535535
return;
536536
}
537537

538+
/* Verify the size fits within the allocation */
539+
if (cdata->num_elems > scontrol->max_size - sizeof(*local_cdata) -
540+
sizeof(*local_cdata->data)) {
541+
dev_err(scomp->dev,
542+
"cdata binary size %u exceeds buffer\n",
543+
cdata->num_elems);
544+
return;
545+
}
546+
538547
/* copy the new binary data */
539548
memcpy(local_cdata->data, cdata->data, cdata->num_elems);
540549
} else if (cdata->num_elems != scontrol->num_channels) {

0 commit comments

Comments
 (0)