Skip to content

smart_amp: bound host-supplied frame, channel and config sizes#10910

Open
lgirdwood wants to merge 5 commits into
thesofproject:mainfrom
lgirdwood:fix-smart-amp
Open

smart_amp: bound host-supplied frame, channel and config sizes#10910
lgirdwood wants to merge 5 commits into
thesofproject:mainfrom
lgirdwood:fix-smart-amp

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Hardening of host-supplied fields in smart_amp so a compromised host cannot
drive out-of-bounds access in the DSP:

  • bound the processed sample count (frames * channels) against the buffer
    capacity, not just the frame count
  • skip out-of-range source channel-map entries instead of indexing past the
    source frame
  • bound the calibration read offset against the calibration data size
  • bound the get-config copy length by the config struct size
  • (sample component) reject channel counts above the platform maximum

No functional change for valid configurations.

lrgirdwo added 5 commits June 11, 2026 14:40
The feed-forward and feedback paths copy frames * channels samples into
fixed intermediate buffers but only checked the frame count. Bound the
total sample count against the buffer capacity so an unexpected channel
count cannot overflow the buffers.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The remap routines used host-provided channel map entries to index the
source frame, guarding only against the -1 unmapped sentinel. Skip any
entry outside [0, source channels) so a crafted map cannot read past the
source frame.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The fragmented calibration get path advanced a read offset by a
host-controlled index without checking it against the calibration data
size, allowing reads past the buffer. Reject offsets at or beyond the
data size and fragments that would extend past it.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The config read-back used the stored config size as the memcpy source
length from a fixed-size struct; a host-set oversized size read adjacent
heap. Bound the length by the struct size as well as the destination.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The sample component took its channel counts from the streams and used
them to index the platform-sized channel map without bounds. Reject
counts above the platform maximum.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Copilot AI review requested due to automatic review settings June 15, 2026 09:45

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 smart_amp against malicious/compromised host-provided parameters to prevent out-of-bounds accesses and unintended data exposure, without changing behavior for valid configurations.

Changes:

  • Adds platform max channel-count validation in the IPC3 sample component prepare path.
  • Tightens bounds checks for buffer sizes (frames × channels), channel map indices, calibration fragment offsets, and get-config copy length.
  • Improves error diagnostics for rejected out-of-range inputs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/samples/audio/smart_amp_test_ipc3.c Rejects in/out channel counts above PLATFORM_MAX_CHANNELS during prepare.
src/audio/smart_amp/smart_amp_maxim_dsm.c Validates calibration fragment offset/length to prevent reading past calibration data.
src/audio/smart_amp/smart_amp_generic.c Skips unmapped and out-of-range channel-map entries to avoid source-frame OOB.
src/audio/smart_amp/smart_amp.c Bounds get-config copy length by struct size; bounds processing by total samples (frames × channels).

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