Skip to content

pcm_converter: reject out-of-range channel map at runtime#10918

Open
lgirdwood wants to merge 1 commit into
thesofproject:mainfrom
lgirdwood:fix-pcm-converter
Open

pcm_converter: reject out-of-range channel map at runtime#10918
lgirdwood wants to merge 1 commit into
thesofproject:mainfrom
lgirdwood:fix-pcm-converter

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

The remap routines validated the host-supplied channel-map nibble only with
an assert(), which is compiled out in release builds, so an out-of-range
value could index past the source frame in production. Fold the bound into
the existing "mute" path so an out-of-range nibble mutes the output instead
of reading out of bounds.

No functional change for valid configurations.

The remap routines validated the source channel nibble only with an
assert, which is compiled out in release builds. Fold the bound into the
existing mute path so an out-of-range nibble mutes the output instead of
indexing past the source frame.

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.

This PR hardens PCM channel remapping by handling out-of-range channel-map nibbles at runtime (instead of relying on assert()), preventing potential out-of-bounds reads in release builds by muting invalid mappings.

Changes:

  • Treat out-of-range chmap nibbles as “mute” during remap to avoid indexing past the source frame.
  • Remove assert(src_channel < num_src_channels) checks that were ineffective in release builds.
  • Apply the same guard behavior across multiple remap variants (c16/c32 and shift/convert paths).

Comment on lines +71 to 77
/* 0xf means "mute"; also mute any out-of-range source channel so
* a crafted chmap nibble cannot index past the source frame.
*/
if (src_channel == 0xf || src_channel >= num_src_channels) {
mute_channel_c16(sink, sink_channel, frames);
continue;
}

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 has a point, but in any case this is an improvement over earlier state of things.

Comment on lines +71 to 77
/* 0xf means "mute"; also mute any out-of-range source channel so
* a crafted chmap nibble cannot index past the source frame.
*/
if (src_channel == 0xf || src_channel >= num_src_channels) {
mute_channel_c16(sink, sink_channel, frames);
continue;
}

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 has a point, but in any case this is an improvement over earlier state of things.

continue;
}

assert(src_channel < num_src_channels);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously this was handled as a fatal error (when debugging was enabled...)

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