Skip to content

Commit dd0eff7

Browse files
committed
ASoC: SOF: ipc3-control: Reject ABI data size larger than the TLV payload
sof_ipc3_bytes_ext_put() copies header.length bytes from user space into cdata->data, but the amount of payload later sent to the firmware is taken from the ABI header's own size field. Nothing checks that the two agree, so a user claiming a size larger than the data it actually provided makes the driver send the stale tail of the previous control value to the DSP. The same stale tail is returned to user space by a subsequent bytes_ext_get() that does not read back from the DSP. Reject the payload if the ABI size field exceeds the data available in the TLV block. header.length has already been verified to be at least sizeof(struct sof_abi_hdr), so the subtraction cannot underflow. Fixes: 67ec2a0 ("ASoC: SOF: Add bytes_ext control IPC ops for IPC3") Cc: stable@vger.kernel.org Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 2240389 commit dd0eff7

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

sound/soc/sof/ipc3-control.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ static int sof_ipc3_bytes_ext_put(struct snd_sof_control *scontrol,
380380
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
381381
struct snd_soc_component *scomp = scontrol->scomp;
382382
struct snd_ctl_tlv header;
383+
unsigned int payload;
383384
int ret = -EINVAL;
384385

385386
/*
@@ -449,6 +450,15 @@ static int sof_ipc3_bytes_ext_put(struct snd_sof_control *scontrol,
449450
goto err_restore;
450451
}
451452

453+
/* header.length has been verified to be >= sizeof(struct sof_abi_hdr) */
454+
payload = header.length - sizeof(struct sof_abi_hdr);
455+
if (cdata->data->size > payload) {
456+
dev_err_ratelimited(scomp->dev,
457+
"ABI header claims %u bytes of data, TLV carries %u\n",
458+
cdata->data->size, payload);
459+
goto err_restore;
460+
}
461+
452462
/* notify DSP of byte control updates */
453463
if (pm_runtime_active(scomp->dev)) {
454464
/* Actually send the data to the DSP; this is an opportunity to validate the data */

0 commit comments

Comments
 (0)