Skip to content

Ipc user handler security fixes#10878

Open
jsarha wants to merge 2 commits into
thesofproject:mainfrom
jsarha:ipc_user_handler_security_fixes
Open

Ipc user handler security fixes#10878
jsarha wants to merge 2 commits into
thesofproject:mainfrom
jsarha:ipc_user_handler_security_fixes

Conversation

@jsarha

@jsarha jsarha commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Couple of security fixes to src/ipc/ipc4/handler-user.c .

Copilot AI review requested due to automatic review settings June 11, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR targets IPC4 user message handling hardening in src/ipc/ipc4/handler-user.c, focusing on safer handling of CHAIN_DMA lifecycle and vendor-config large payload parsing.

Changes:

  • Removes an extra list_item_del() in the CHAIN_DMA path after state processing.
  • Moves vendor-config data_off_size validation earlier to guard host-controlled size before use.

Comment thread src/ipc/ipc4/handler-user.c Outdated
Comment on lines +1109 to +1111
/* Validate the host-controlled payload size before any use or arithmetic. */
if (data_off_size < sizeof(struct sof_tlv) || data_off_size > MAILBOX_HOSTBOX_SIZE)
return IPC4_INVALID_CONFIG_DATA_STRUCT;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kv2019i , now fixed.

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the copilot comment is right, the non-initial configs may be smaller than the tlv header, so this would reject valid IPCs...

Jyri Sarha added 2 commits June 12, 2026 11:59
ipc4_set_vendor_config_module_instance() only validated data_off_size in
the bursted-config path (init_block && final_block). The else path with
init_block == 1 && final_block == 0 unconditionally executed:

	data += sizeof(struct sof_tlv);
	data_off_size -= sizeof(struct sof_tlv);

data_off_size is a host-controlled 20-bit field taken straight from the
IPC message. When it is smaller than sizeof(struct sof_tlv) (8) the
subtraction underflows and wraps to a value close to 0xFFFFFFFF, which is
then forwarded as the length to the module's set_large_config() handler.
The actual backing buffer is only the MAILBOX_HOSTBOX_SIZE mailbox, so a
compromised host could trigger out-of-bounds reads of DSP SRAM (and
possible corruption depending on the target module) by sending
MOD_LARGE_CONFIG_SET with init_block=1, final_block=0 and
data_off_size < 8.

Hoist the existing "data_off_size < sizeof(struct sof_tlv) ||
data_off_size > MAILBOX_HOSTBOX_SIZE" bounds check to the top of the
function so it runs for every entry, before any pointer or size
arithmetic. The duplicate check in the bursted-config branch is removed
as it is now covered by the hoisted one.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
ipc4_process_chain_dma() called ipc4_chain_dma_state() and then, on the
deallocate path (allocate == 0 && enable == 0), unconditionally executed
list_item_del(&cdma_comp->list).

However, on that same deallocate path ipc4_chain_dma_state() already
unlinks the matching ipc_comp_dev from ipc->comp_list and frees it with
rfree():

	list_item_del(&icd->list);
	rfree(icd);

Since icd is the same object as cdma_comp, the subsequent
list_item_del(&cdma_comp->list) in the caller dereferenced and wrote to
already-freed memory (prev->next / next->prev), a use-after-free. With
heap grooming a host sending GLB_CHAIN_DMA with allocate=0/enable=0 on an
existing chain could turn this into controlled heap corruption.

The unlink-before-free is already handled correctly by
ipc4_chain_dma_state(), so the duplicate list_item_del() in the caller is
both redundant and unsafe. Remove it.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the ipc_user_handler_security_fixes branch from 121da6d to 3ca57ac Compare June 12, 2026 09:09
Comment on lines +1113 to +1116
if (data_off_size > MAILBOX_HOSTBOX_SIZE)
return IPC4_INVALID_CONFIG_DATA_STRUCT;
if (init_block && data_off_size < sizeof(struct sof_tlv))
return IPC4_INVALID_CONFIG_DATA_STRUCT;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be fixed later or in update, but we need unique error LOG messages for each failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants