Skip to content

audio: module_adapter: clear pipeline back-pointers on create failure - #11158

Open
tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/ipc4/module_adapter/dev_cleanup
Open

audio: module_adapter: clear pipeline back-pointers on create failure#11158
tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/ipc4/module_adapter/dev_cleanup

Conversation

@tmleman

@tmleman tmleman commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

A module's init op can store its comp_dev into the parent pipeline's source_comp/sink_comp before module creation completes. When a later step of module_adapter_new_ext fails, the dev is freed on the err: path before it has been added to the IPC component list, so ipc_comp_free back-pointer cleanup never runs for it and
pipeline->source_comp/sink_comp is left pointing at freed memory.

A subsequent SET_PIPELINE_STATE then dereferences the freed component in ipc4 pipeline_get_host_dev.

Found by the IPC4 libFuzzer target under AddressSanitizer.

Clear pipeline->source_comp/sink_comp/sched_comp that reference the dev being freed on the creation-failure path, mirroring the cleanup ipc_comp_free already performs for registered components.

Copilot AI lite review requested due to automatic review settings September 2, 2026 12:35
@tmleman
tmleman requested a review from ranj063 as a code owner September 2, 2026 12:35

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 change directly addresses a concrete UAF on the creation-failure path with targeted, low-risk pointer cleanup consistent with existing ipc_comp_free() behavior.

Pull request overview

Fixes a use-after-free scenario in IPC4 pipeline handling where a module’s init path can stash a comp_dev * into pipeline->source_comp / sink_comp / sched_comp before module_adapter_new_ext() finishes successfully, leaving stale back-pointers if creation later fails and the dev is freed.

Changes:

  • Clear pipeline->source_comp, pipeline->sink_comp, and pipeline->sched_comp if they reference the component being freed on the module_adapter_new_ext() error path.
  • Mirror the back-pointer cleanup behavior already present in ipc_comp_free() for fully-registered components, but apply it to the pre-registration failure path.
File summaries
File Description
src/audio/module_adapter/module_adapter.c Adds error-path cleanup to null pipeline back-pointers to a just-freed component, preventing later dereferences in IPC4 pipeline state transitions.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@intel-sofci

intel-sofci commented Sep 2, 2026

Copy link
Copy Markdown

PR 11158: test results

Run date: 2026-09-02 19:41 UTC

Tested commit: 6b80e8a1d477bd41d50a482600594f081ffc9278

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

A module's init op can store its comp_dev into the parent pipeline's
source_comp/sink_comp before module creation completes. When a later
step of module_adapter_new_ext fails, the dev is freed on the err: path
before it has been added to the IPC component list, so ipc_comp_free
back-pointer cleanup never runs for it and
pipeline->source_comp/sink_comp is left pointing at freed memory.

A subsequent SET_PIPELINE_STATE then dereferences the freed component in
ipc4 pipeline_get_host_dev.

Found by the IPC4 libFuzzer target under AddressSanitizer.

Clear pipeline->source_comp/sink_comp/sched_comp that reference the dev
being freed on the creation-failure path, mirroring the cleanup
ipc_comp_free already performs for registered components.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
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.

4 participants