Skip to content

audio: smart_amp_test: bound config size to struct size in get_config - #11202

Open
tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/samples/ipc3/smart_amp_test/fix_oob_read
Open

tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/samples/ipc3/smart_amp_test/fix_oob_read

Conversation

@tmleman

@tmleman tmleman commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

smart_amp_get_config() copies sad->config.size (bs) bytes from &sad->config into the host reply buffer, but only validated bs against the destination bound (size, the IPC max_data_size), never against the actual size of the source: sizeof(struct sof_smart_amp_config).

sad->config.size is host-influenced: smart_amp_new() copies a create-time blob (including the embedded size field) into sad->config without validating that field, so a crafted blob can store an arbitrary size. A crafted blob (config.size = 247) followed by a binary GET_DATA request makes the DSP read 223 bytes past the 24-byte config, reported by AddressSanitizer as a use-after-poison read.

Fix by validating bs against sizeof(struct sof_smart_amp_config) too, at the point of use, rejecting any oversized .size before it is used as a read length. This is the same pattern used for the channel-count bound added in commit 1007de2 ("smart_amp_test: bound channel counts to platform max").

Copilot AI lite review requested due to automatic review settings September 15, 2026 11:27

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.

🟢 Approval recommended

The oversized-read issue is addressed with no unresolved blocking concerns.

Pull request overview

Hardens IPC3 smart amplifier config retrieval by bounding host-controlled copy lengths to the configuration struct size.

Changes:

  • Rejects oversized configuration lengths.
  • Prevents out-of-bounds source reads.
File summaries
File Description
src/samples/audio/smart_amp_test_ipc3.c Adds source-size validation before copying configuration data.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@intel-sofci

intel-sofci commented Sep 15, 2026

Copy link
Copy Markdown

PR 11202: test results

Run date: 2026-09-15 12:23 UTC

Tested commit: 326a04f5884830590c8230e3fb621db74592028c

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

smart_amp_get_config() copies sad->config.size (bs) bytes from
&sad->config into the host reply buffer, but only validated bs against
the destination bound (size, the IPC max_data_size), never against the
actual size of the source: sizeof(struct sof_smart_amp_config).

sad->config.size is host-influenced: smart_amp_new() copies a
create-time blob (including the embedded size field) into sad->config
without validating that field, so a crafted blob can store an arbitrary
size. A crafted blob (config.size = 247) followed by a binary GET_DATA
request makes the DSP read 223 bytes past the 24-byte config, reported
by AddressSanitizer as a use-after-poison read.

Fix by validating bs against sizeof(struct sof_smart_amp_config) too, at
the point of use, rejecting any oversized .size before it is used as a
read length. This is the same pattern used for the channel-count bound
added in commit 1007de2 ("smart_amp_test: bound channel counts to
platform max").

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
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