Skip to content

rtnr: clamp host-supplied control element counts#10911

Merged
kv2019i merged 1 commit into
thesofproject:mainfrom
lgirdwood:fix-rtnr
Jun 18, 2026
Merged

rtnr: clamp host-supplied control element counts#10911
kv2019i merged 1 commit into
thesofproject:mainfrom
lgirdwood:fix-rtnr

Conversation

@lgirdwood

@lgirdwood lgirdwood commented Jun 15, 2026

Copy link
Copy Markdown
Member

The SWITCH control get and set handlers looped over a host-supplied element
count while reading/writing the control channel array, which could run past
the IPC payload. Reject counts larger than SOF_IPC_MAX_CHANNELS in both
handlers before the loop.

No functional change for valid configurations.

Copilot AI review requested due to automatic review settings June 15, 2026 09:45

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.

Adds bounds-checking for host-supplied SWITCH control element counts in rtnr get/set handlers to prevent reading/writing past the IPC payload.

Changes:

  • Validate cdata->num_elems against SOF_IPC_MAX_CHANNELS in rtnr_get_config().
  • Validate cdata->num_elems against SOF_IPC_MAX_CHANNELS in rtnr_set_value().

Comment thread src/audio/rtnr/rtnr.c
Comment on lines +457 to +461
if (cdata->num_elems > SOF_IPC_MAX_CHANNELS) {
comp_err(dev, "rtnr_get_config() error: num_elems %u out of range",
cdata->num_elems);
return -EINVAL;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reworded — the behaviour is intentional rejection (a control message with more elements than channels is malformed). I consolidated the get/set changes into a single commit titled "rtnr: reject out-of-range control switch element counts" and updated the PR description to match.

Comment thread src/audio/rtnr/rtnr.c
Comment on lines +568 to +572
if (cdata->num_elems > SOF_IPC_MAX_CHANNELS) {
comp_err(dev, "rtnr_set_value() error: num_elems %u out of range",
cdata->num_elems);
return -EINVAL;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed — both messages now include the limit: num_elems %u > max %u (with SOF_IPC_MAX_CHANNELS).

@abonislawski abonislawski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@lgirdwood looks like there are 2 accidentally added txt files?

Comment thread src/audio/rtnr/rtnr.c Outdated

case SOF_CTRL_CMD_SWITCH:
if (cdata->num_elems > SOF_IPC_MAX_CHANNELS) {
comp_err(dev, "rtnr_get_config() error: num_elems %u > max %u",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"rtnr_get_config()" func name duplicate not needed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done — dropped the rtnr_get_config() prefix; the message is now just "num_elems %u > max %u" (comp_err already tags the component/function context).

Comment thread src/audio/rtnr/rtnr.c Outdated
int32_t j;

if (cdata->num_elems > SOF_IPC_MAX_CHANNELS) {
comp_err(dev, "rtnr_set_value() error: num_elems %u > max %u",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"rtnr_set_value()" func name duplicate not needed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done — same here, dropped the rtnr_set_value() prefix.

@singalsu singalsu left a comment

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.

The alsa-info.txt and dump.txt look like accidentally included to this PR.

Comment thread alsa-info.txt.FHAbsCozCK Outdated
@@ -0,0 +1,5744 @@
upload=true&script=true&cardinfo=

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.

are these two files needed here? Don't seem related to rtnr. Supposedly a bad commit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right — those two files (alsa-info.txt..., dell-arl-dump.txt) were unrelated local files accidentally swept in by a git add -A. Removed them; the branch now contains only the rtnr.c change. Sorry about that.

@lgirdwood

Copy link
Copy Markdown
Member Author

The alsa-info.txt and dump.txt look like accidentally included to this PR.

They do indeed, no idea why Claude would add debug to the PR. This sound like an addition to agent workflow, i.e check commit for log files and remove before commit.

The SWITCH control get and set handlers looped over a host-supplied
element count while reading/writing the control channel array, which
could run past the IPC payload. Reject counts larger than the maximum
channel count in both handlers before the loop.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
@kv2019i kv2019i merged commit fdbf856 into thesofproject:main Jun 18, 2026
45 checks passed
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.

7 participants