Skip to content

audio: data_blob: fail gracefully on oversized SET fragment - #11267

Open
tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/ipc3/audio/data_blob/fail_gracefully
Open

tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/ipc3/audio/data_blob/fail_gracefully

Conversation

@tmleman

@tmleman tmleman commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

comp_data_blob_set_cmd() reassembles a host-provided blob from multiple SOF_IPC_COMP_SET_DATA fragments. cdata->num_elems and cdata->data->size are host-controlled. When a fragment's num_elems exceeds the remaining capacity (new_data_size - data_pos), memcpy_s() correctly refuses the copy and returns non-zero, but the following assert(!ret) then panics the DSP. A single malformed host SET request (small declared size, larger num_elems) is therefore enough to crash the firmware.

Replace the assert with a graceful error path that frees and resets the in-progress blob state and returns the error to the IPC caller, mirroring the earlier IPC4 fix in ipc4_comp_data_blob_set() (commit 93be3b1). The destination size passed to memcpy_s() was already correct, so no bound is changed and legitimate transfers are unaffected.

Found by libFuzzer IPC3/UBSan; all six reproducers now return cleanly and the ipc3 corpus (44828 runs) shows no regression.

Copilot AI balanced review requested due to automatic review settings October 5, 2026 09:08

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.

Copilot review overview

🟡 Changes recommended

The new deallocator call omits its required handler argument and will not compile.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Prevents malformed IPC3 blob fragments from panicking firmware by handling copy failures gracefully.

Changes:

  • Frees and resets partial blob state when memcpy_s() fails.
  • Returns the copy error to the IPC caller.
File Description
src/​audio/​data_blob.c Adds graceful oversized-fragment error handling.

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

Comment thread src/audio/data_blob.c Outdated
@tmleman
tmleman force-pushed the topic/upstream/pr/ipc3/audio/data_blob/fail_gracefully branch from ef897c0 to b67f66b Compare October 5, 2026 09:13
@tmleman
tmleman requested a balanced review from Copilot October 5, 2026 09:20

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.

Copilot review overview

🟢 Approval recommended

The focused error path safely mirrors established IPC4 cleanup behavior with no unresolved issues.

Review effort: Balanced
Findings: None

Resolved since last review (1)

comp_data_blob_set_cmd() reassembles a host-provided blob from multiple
SOF_IPC_COMP_SET_DATA fragments. cdata->num_elems and cdata->data->size
are host-controlled. When a fragment's num_elems exceeds the remaining
capacity (new_data_size - data_pos), memcpy_s() correctly refuses the
copy and returns non-zero, but the following assert(!ret) then panics
the DSP. A single malformed host SET request (small declared size,
larger num_elems) is therefore enough to crash the firmware.

Replace the assert with a graceful error path that frees and resets the
in-progress blob state and returns the error to the IPC caller,
mirroring the earlier IPC4 fix in ipc4_comp_data_blob_set() (commit
93be3b1). The destination size passed to memcpy_s() was already
correct, so no bound is changed and legitimate transfers are unaffected.

Found by libFuzzer IPC3/UBSan; all six reproducers now return cleanly
and the ipc3 corpus (44828 runs) shows no regression.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
@intel-sofci

Copy link
Copy Markdown

PR 11267: test results

Run date: 2026-10-05 10:59 UTC

Tested commit: b67f66b09ca7ef793590948934071a5f21513007

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.

3 participants