Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused bounds check and fade guards address the unsafe accesses and division without identified blocking issues.
No open issues 🎉
What changed in this PR
Hardens copier initialization against undersized DMIC gateway blobs and zero-length fades.
Changes:
- Rejects DMIC blobs that do not contain the global configuration before reading fade and silence parameters.
- Prevents division by zero in both fade implementations when the calculated fade length is zero.
| File | Description |
|---|---|
| src/audio/copier/copier_hifi.c | Skips fade-step calculation for zero-length fades. |
| src/audio/copier/copier_generic.c | Adds the same zero-length guard to the generic implementation. |
| src/audio/copier/copier_gain.c | Validates DMIC blob length before accessing global configuration. |
Review effort: Balanced
copier_gain_set_params() casts the copier gateway blob to a struct
dmic_config_data and reads the fade-in and silence periods from its
global config, 20 bytes into the blob. The blob is copied into the
copier instance with the host-supplied gtw_cfg.config_length (in
dwords), and nothing required that length to cover the global config:
ipc4_find_dma_config() only looks for a DMA-config TLV.
An IPC4 INIT_INSTANCE for a copier with a DMIC link input gateway and
config_length = 0 therefore reads past the end of the instance
allocation. ASan reports it on native_sim as:
use-after-poison ... READ of size 4
copier_gain_set_params src/audio/copier/copier_gain.c:43
copier_dai_init src/audio/copier/copier_dai.c:262
copier_dai_create src/audio/copier/copier_dai.c:380
copier_init src/audio/copier/copier.c:237
Require the blob to be at least as long as the global config before
dereferencing it, and reject the malformed gateway configuration
otherwise.
Assisted-by: Copilot:claude-opus-4.8
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
copier_gain_set_fade_params() divides INT64_MAX by fade_sg_length, which is computed as frames * fade_period where frames is the host-supplied sampling frequency divided by the pipeline period and fade_period comes from the DMIC gateway blob. Both inputs are host-controlled, so the product can be zero: a DMIC copier created with a sampling frequency below the pipeline period rate makes frames zero and the division faults (SIGFPE in __udivdi3, reported by ASan as "FPE on unknown address"). A zero fade length simply means no fade segment, which is already the documented behaviour of the GAIN_ZERO_TRANS_MS case just above, so return early with the fade disabled instead of computing a step for it. Apply the same guard to the generic and HiFi implementations. Found while verifying a well-formed DMIC gateway blob against the preceding blob-length fix on an IPC4 + ASan native_sim build. Assisted-by: Copilot:claude-opus-4.8 Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
PR 11367: test resultsRun date: 2026-10-27 15:33 UTC Tested commit: 00ed003d2693e7c115ec16a6b5b98a8b6bc8b0f6 |
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.
copier_gain_set_params() casts the copier gateway blob to a struct
dmic_config_data and reads the fade-in and silence periods from its
global config, 20 bytes into the blob. The blob is copied into the
copier instance with the host-supplied gtw_cfg.config_length (in
dwords), and nothing required that length to cover the global config:
ipc4_find_dma_config() only looks for a DMA-config TLV.
An IPC4 INIT_INSTANCE for a copier with a DMIC link input gateway and
config_length = 0 therefore reads past the end of the instance
allocation. ASan reports it on native_sim as:
Require the blob to be at least as long as the global config before
dereferencing it, and reject the malformed gateway configuration
otherwise.
Assisted-by: Copilot:claude-opus-4.8