Skip to content

testbench: ipc4: bound mixer max against volume table size - #11304

Open
Shrusti-pk wants to merge 1 commit into
thesofproject:mainfrom
Shrusti-pk:testbench-mixer-max-bound
Open

Shrusti-pk wants to merge 1 commit into
thesofproject:mainfrom
Shrusti-pk:testbench-mixer-max-bound

Conversation

@Shrusti-pk

Copy link
Copy Markdown
Contributor

tb_kcontrol_cb_new populates a fixed volume_table[TB_MAX_VOLUME_SIZE] (120) from a VOLSW mixer control in the topology file:

  • the fill loop runs i over [0, tplg_mixer->max], and max is the __u32 copied straight from the .tplg blob with no upper bound
  • a control declaring max >= 120 writes past volume_table and the rest of struct tb_ctl; a large max runs far past the glb->ctl allocation (ASan reports WRITE 0 bytes after a 640-byte region)
  • max + 1 also wraps to 0 when max is UINT32_MAX

Reject max >= TB_MAX_VOLUME_SIZE before the loop. The later volume_table[control_values[i]] reads are limited to the same max, so they stay in bounds too.

tb_kcontrol_cb_new() fills ctl->volume_table[i] for i in [0, tplg_mixer->max]
while loading a VOLSW mixer control from a topology file. volume_table is a
fixed unsigned int[TB_MAX_VOLUME_SIZE] (120) in struct tb_ctl, but max is the
__u32 field copied verbatim from the topology blob with no upper bound, so a
control declaring max >= 120 writes past volume_table and the rest of the
struct, and a large max runs far past the glb->ctl allocation. max + 1 also
wraps to 0 when max is UINT32_MAX.

Reject max >= TB_MAX_VOLUME_SIZE before the fill loop. This also keeps the
later volume_table[control_values[i]] reads in bounds, as they are limited to
the same max.

Signed-off-by: Shrushti P K <shrusthi@labs.digiscrypt.com>
@Shrusti-pk
Shrusti-pk requested a review from ranj063 as a code owner October 14, 2026 09:02
@sofci

sofci commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

@lgirdwood

Copy link
Copy Markdown
Member

test this please

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