Skip to content

ipc4: helper: bound host TLV length in DMA config walk#10915

Open
abonislawski wants to merge 1 commit into
thesofproject:mainfrom
abonislawski:fix/ipc-helper-tlv
Open

ipc4: helper: bound host TLV length in DMA config walk#10915
abonislawski wants to merge 1 commit into
thesofproject:mainfrom
abonislawski:fix/ipc-helper-tlv

Conversation

@abonislawski

Copy link
Copy Markdown
Member

Reject a gateway-config TLV whose length overruns the buffer so the uintptr_t walk cannot wrap past the low address space.

Reject a gateway-config TLV whose length overruns the buffer
so the uintptr_t walk cannot wrap past the low address space.

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Copilot AI review requested due to automatic review settings June 15, 2026 11:20

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

Note

Copilot was unable to run its full agentic suite in this review.

Hardens the DMA config TLV walk against malformed host TLVs by bounding TLV length checks so pointer arithmetic can’t wrap and walk out of the provided buffer.

Changes:

  • Switches end-address arithmetic and comparisons to uintptr_t for correct pointer-width handling.
  • Adds a per-TLV bounds check to reject TLVs whose declared length would overrun the buffer and potentially break tlv_next().

Comment thread src/ipc/ipc4/helper.c
uint32_t size, uint32_t device_id, int dma_cfg_idx)
{
uint32_t end_addr = (uint32_t)data_buffer + size;
uintptr_t end_addr = (uintptr_t)data_buffer + size;

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.

I do not really follow what Copilot is trying to suggest here. If the end_addr wraps, then the loop bellow will end immediately and no harm is done. The code of course does not work and function would return an error, but that is correct behaviour since the arguments are invalid.

@jsarha jsarha 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.

LGTM

Comment thread src/ipc/ipc4/helper.c
uint32_t size, uint32_t device_id, int dma_cfg_idx)
{
uint32_t end_addr = (uint32_t)data_buffer + size;
uintptr_t end_addr = (uintptr_t)data_buffer + size;

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.

I do not really follow what Copilot is trying to suggest here. If the end_addr wraps, then the loop bellow will end immediately and no harm is done. The code of course does not work and function would return an error, but that is correct behaviour since the arguments are invalid.

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.

3 participants