audio: smart_amp: validate DSM parameter id before db write#10887
Merged
lgirdwood merged 1 commit intoJun 12, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_parambefore indexingdb[]. - Log an error and return
-EINVALwhen 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>
serhiy-katsyuba-intel
approved these changes
Jun 12, 2026
kv2019i
approved these changes
Jun 12, 2026
| 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) { |
Collaborator
There was a problem hiding this comment.
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
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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[].