Skip to content

Commit c9570be

Browse files
committed
ipc3: avoid overflow in the process size bounds check
The bounds check added two host-supplied 32-bit sizes, which could wrap and let an oversized value pass. Compare without adding by subtracting from the maximum instead. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 89adb95 commit c9570be

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/ipc/ipc3/helper.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ static int comp_specific_builder(struct sof_ipc_comp *comp,
302302
if (IPC_TAIL_IS_SIZE_INVALID(*proc))
303303
return -EBADMSG;
304304

305-
if (proc->comp.hdr.size + proc->size > SOF_IPC_MSG_MAX_SIZE)
305+
/* compare without adding the two host-supplied uint32_t values,
306+
* which could wrap and let an oversized proc->size pass
307+
*/
308+
if (proc->comp.hdr.size > SOF_IPC_MSG_MAX_SIZE ||
309+
proc->size > SOF_IPC_MSG_MAX_SIZE - proc->comp.hdr.size)
306310
return -EBADMSG;
307311

308312
config->process.type = proc->type;

0 commit comments

Comments
 (0)