Skip to content

Commit af6c200

Browse files
lrgirdwolgirdwood
authored andcommitted
tplg: reject undersized process private data
The private-data size had the ABI header length subtracted without checking it was at least that large, underflowing the computed size. Reject private data smaller than the header in both append paths. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 6767965 commit af6c200

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tools/tplg_parser/process.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ static int process_append_data3(void *_process_ipc,
151151

152152
/* Size is process IPC plus private data minus ABI header */
153153
bytes_ctl = (struct snd_soc_tplg_bytes_control *)ctl;
154+
if (bytes_ctl->priv.size < sizeof(struct sof_abi_hdr)) {
155+
fprintf(stderr, "error: process priv data too small: %u\n",
156+
bytes_ctl->priv.size);
157+
return -EINVAL;
158+
}
154159
size = bytes_ctl->priv.size - sizeof(struct sof_abi_hdr);
155160
ipc_size = sizeof(struct sof_ipc_comp_process) + UUID_SIZE +
156161
process_ipc->size + size;
@@ -184,6 +189,11 @@ static int process_append_data4(void *_process_ipc,
184189

185190
/* Size is process IPC plus private data minus ABI header */
186191
bytes_ctl = (struct snd_soc_tplg_bytes_control *)ctl;
192+
if (bytes_ctl->priv.size < sizeof(struct sof_abi_hdr)) {
193+
fprintf(stderr, "error: process priv data too small: %u\n",
194+
bytes_ctl->priv.size);
195+
return -EINVAL;
196+
}
187197
size = bytes_ctl->priv.size - sizeof(struct sof_abi_hdr);
188198

189199
/* validate if everything will fit */

0 commit comments

Comments
 (0)