Skip to content

audio: smart_amp: validate DSM parameter id before db write#10887

Merged
lgirdwood merged 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/ipc3/smart_amp/add_check_for_id
Jun 12, 2026
Merged

audio: smart_amp: validate DSM parameter id before db write#10887
lgirdwood merged 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/ipc3/smart_amp/add_check_for_id

Conversation

@tmleman

@tmleman tmleman commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

maxim_dsm_set_param() masks the host-supplied parameter id with DSM_CH_MASK() and uses the result directly as an index into the model database db[], which is sized for hspk->param.max_param parameters. A larger id leads to an out-of-bounds write.

Reject id values that are not below max_param before indexing db[].

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 pull request hardens the Maxim DSM smart amplifier control path by validating host-supplied DSM parameter IDs before using them to index the model database, preventing out-of-bounds writes.

Changes:

  • Add a bounds check in maxim_dsm_set_param() to reject parameter IDs >= hspk->param.max_param before indexing db[].
  • Log an error and return -EINVAL when an invalid parameter ID is received.

maxim_dsm_set_param() masks the host-supplied parameter id with
DSM_CH_MASK() and uses the result directly as an index into the
model database db[], which is sized for hspk->param.max_param
parameters. A larger id leads to an out-of-bounds write.

Reject id values that are not below max_param before indexing db[].

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
ch = (param->param.id & DSM_CH1_BITMASK) ? 0 : 1;

/* id indexes the model database; reject values past its size */
if (id >= hspk->param.max_param) {

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.

This is not very obvious but this seems the correct thing to do. DSM_CH_MASK is "((cmd_id) & 0x00FFFFFF)", so this the number to check.

@lgirdwood lgirdwood merged commit 2575428 into thesofproject:main Jun 12, 2026
45 checks passed
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.

5 participants