Skip to content

Commit c9e2c27

Browse files
committed
ipc4: handler: bounds-check multi-pipeline SET_PIPELINE_STATE count
For multi_ppl=1, ipc4_set_pipeline_state() takes pipelines_count straight from the host mailbox and uses it as the ppl_id[] loop bound, with no validation against the mailbox size. The IPC4 fuzzer reached this path with a 6-byte input that decodes to type=SOF_IPC4_GLB_SET_PIPELINE_STATE, multi_ppl=1 and a count field that easily exceeds MAILBOX_HOSTBOX. Once an earlier testcase had created a matching pipeline, the ppl_id[i] read walked past the end of the hostbox and AddressSanitizer reported a heap-buffer overflow. Cap pipelines_count at what the hostbox can actually hold and reject oversized requests with IPC4_ERROR_INVALID_PARAM, logging the offending count via ipc_cmd_err() for parity with the surrounding handlers. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent b20c57b commit c9e2c27

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/ipc/ipc4/handler-user.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,21 @@ static int ipc4_set_pipeline_state(struct ipc4_message_request *ipc4)
441441

442442
if (state.extension.r.multi_ppl) {
443443
ppl_count = ppl_data->pipelines_count;
444+
/*
445+
* pipelines_count is read straight from the host-provided
446+
* mailbox payload, so cap it at what the mailbox can
447+
* physically hold. Anything larger means the host promised
448+
* more ppl_id[] entries than fit in MAILBOX_HOSTBOX, and
449+
* dereferencing the flex array would read out of bounds.
450+
*/
451+
if (ppl_count > (MAILBOX_HOSTBOX_SIZE -
452+
sizeof(struct ipc4_pipeline_set_state_data)) /
453+
sizeof(uint32_t)) {
454+
ipc_cmd_err(&ipc_tr,
455+
"ipc: pipelines_count %u exceeds mailbox bound",
456+
ppl_count);
457+
return IPC4_ERROR_INVALID_PARAM;
458+
}
444459
ppl_id = ppl_data->ppl_id;
445460
dcache_invalidate_region((__sparse_force void __sparse_cache *)ppl_id,
446461
sizeof(int) * ppl_count);

0 commit comments

Comments
 (0)