Skip to content

audio: copier: bound DMIC gateway blob before reading fade params - #11367

Open
tmleman wants to merge 2 commits into
thesofproject:mainfrom
tmleman:topic/upstream/pr/copier/dmic/blob_validation
Open

tmleman wants to merge 2 commits into
thesofproject:mainfrom
tmleman:topic/upstream/pr/copier/dmic/blob_validation

Conversation

@tmleman

@tmleman tmleman commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

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

Copilot AI balanced review requested due to automatic review settings October 27, 2026 15:04

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.

🟢 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>
@intel-sofci

intel-sofci commented Oct 27, 2026 •

Copy link
Copy Markdown

PR 11367: test results

Run date: 2026-10-28 12:25 UTC

Tested commit: 00ed003d2693e7c115ec16a6b5b98a8b6bc8b0f6

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

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