Skip to content

volume: validate host-supplied config and fix init error path#10919

Open
lgirdwood wants to merge 3 commits into
thesofproject:mainfrom
lgirdwood:fix-volume
Open

volume: validate host-supplied config and fix init error path#10919
lgirdwood wants to merge 3 commits into
thesofproject:mainfrom
lgirdwood:fix-volume

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Hardening of host-supplied data in the volume component, plus an error-path
fix:

  • avoid a use-after-free in the IPC3 init error path (the component data was
    freed and then dereferenced)
  • validate the IPC4 init payload is large enough to cover the per-channel
    config array before iterating it
  • require a full 32-bit word for the attenuation control payload

No functional change for valid configurations.

lrgirdwo added 3 commits June 11, 2026 14:40
On an invalid ramp type the init error path freed the component data
then read a field from it. Free the dependent allocation before the
component data and stop dereferencing it afterwards.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Init read a per-channel config array sized by the channel count from the
init payload without checking the payload was large enough, reading past
the mailbox. Require the payload to cover the base config and all
per-channel entries.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The attenuation setter only rejected oversized payloads, then
dereferenced the data as a 32-bit value; a shorter payload read past the
mailbox. Require exactly a 32-bit payload.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Copilot AI review requested due to automatic review settings June 15, 2026 14:56

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Hardens the volume component against malformed host-supplied IPC payloads and fixes a use-after-free in an IPC3 init error path.

Changes:

  • Add IPC4 init payload size validation before iterating per-channel config.
  • Tighten attenuation control payload validation to require exactly 32 bits.
  • Fix IPC3 init error cleanup order to avoid dereferencing freed memory.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/audio/volume/volume_ipc4.c Adds IPC4 init/config size validation and tightens attenuation payload size checks.
src/audio/volume/volume_ipc3.c Adjusts error-path frees to avoid a use-after-free during init failure.

Comment on lines +133 to +137
if (cfg->size < sizeof(*vol) + channels_count * sizeof(vol->config[0])) {
comp_err(dev, "Invalid init payload size %zu for %u channels",
cfg->size, channels_count);
return -EINVAL;
}
Comment on lines +283 to 286
if (data_size < (int)sizeof(uint32_t) || data_size > sizeof(uint32_t)) {
comp_err(dev, "attenuation data size %d is incorrect", data_size);
return -EINVAL;
}
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