module_adapter: validate config sizes and isolate per-instance state#10920
Open
lgirdwood wants to merge 3 commits into
Open
module_adapter: validate config sizes and isolate per-instance state#10920lgirdwood wants to merge 3 commits into
lgirdwood wants to merge 3 commits into
Conversation
The init path read the direction word at a fixed offset past the codec params without checking the payload was large enough, reading past the mailbox. Require the payload to cover the field. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The config parse loop read a parameter header before confirming a whole header remained in the blob, reading past it near the end. Bound the read by the remaining size. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The reassembly size for fragmented runtime-params transfers was a file-scope static shared by every component, so interleaved transfers to different components corrupted each other's state. Move it into per-instance module state. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Hardens module_adapter and codec wrappers by validating configuration buffer sizes before dereferencing and by isolating fragmented transfer reassembly state per component instance to avoid cross-component corruption.
Changes:
- Added per-instance
runtime_params_sizetoprocessing_moduleto track fragmented runtime-params transfer size. - Added bounds checks in Waves TLV parsing and Cadence init parsing to prevent out-of-bounds reads.
- Updated IPC3 module_adapter get/set params path to use per-instance reassembly size instead of a static.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/include/module/module/base.h | Adds per-instance field for fragmented transfer reassembly sizing. |
| src/audio/module_adapter/module_adapter_ipc3.c | Switches from static reassembly size to per-instance state. |
| src/audio/module_adapter/module/waves/waves.c | Adds header-size bounds check before reading TLV header fields. |
| src/audio/module_adapter/module/cadence_ipc4.c | Validates init payload is large enough before reading direction word. |
Comment on lines
276
to
277
| init_bytes = (uint8_t *)ext_data->module_data; | ||
| cd->direction = *(uint32_t *)(init_bytes + sizeof(struct snd_codec)); |
Comment on lines
+618
to
+622
| if (index + header_size > cfg->size) { | ||
| comp_err(dev, "module_param header exceeds cfg buffer size: %d", | ||
| cfg->size); | ||
| return -EINVAL; | ||
| } |
| * across all module_adapter components and corrupted by interleaved | ||
| * fragmented transfers | ||
| */ | ||
| uint32_t *size = &mod->runtime_params_size; |
Comment on lines
+121
to
+125
| /* total size of a fragmented runtime-params (get/set) transfer, kept | ||
| * per instance so concurrent transfers to different components do not | ||
| * corrupt each other's reassembly state | ||
| */ | ||
| uint32_t runtime_params_size; |
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.
Hardening of the module_adapter and a couple of codec wrappers:
direction field past the codec params
file-scope static into per-instance state, so interleaved transfers to
different components can't corrupt each other
No functional change for valid configurations.