Skip to content

audio: kpb: IPC handling hardening#10901

Open
tmleman wants to merge 3 commits into
thesofproject:mainfrom
tmleman:topic/upstream/pr/audio/kpb/fix/add_more_checks
Open

audio: kpb: IPC handling hardening#10901
tmleman wants to merge 3 commits into
thesofproject:mainfrom
tmleman:topic/upstream/pr/audio/kpb/fix/add_more_checks

Conversation

@tmleman

@tmleman tmleman commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Those commits harden the KPB IPC4 large-config paths: they validate the host-supplied channel count in kpb_set_micselect() (preventing an unsigned underflow and out-of-bounds writes) and validate the FMT module list against the actual payload length in the KP_BUF_CFG_FM_MODULE path (preventing out-of-bounds reads). The third commit makes prepare_fmt_modules_list() roll back partially populated FMT entries on error and adds a defensive outpin_idx bound check, so a failed configuration no longer leaves stale component references.

Copilot AI review requested due to automatic review settings June 12, 2026 14:02

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 KPB IPC4 large-config handling to prevent malformed host payloads from causing out-of-bounds reads/writes, and ensures partially applied FMT configuration is rolled back on error.

Changes:

  • Validate micselector payload size and channel count before computing masks/offsets.
  • Validate KP_BUF_CFG_FM_MODULE payload length against declared module count.
  • Add rollback/cleanup in prepare_fmt_modules_list() and defensively bound-check outpin_idx.

Comment thread src/audio/kpb.c
Comment thread src/audio/kpb.c
@tmleman tmleman force-pushed the topic/upstream/pr/audio/kpb/fix/add_more_checks branch from 7dcbd90 to d24e307 Compare June 12, 2026 15:04
tmleman added 3 commits June 12, 2026 18:24
kpb_set_micselect() computed mic_cnt = channels -
KPB_REFERENCE_SUPPORT_CHANNELS without checking the lower bound. With
a host-configured channel count below 2 the unsigned subtraction
wraps, producing a huge loop bound and out-of-bounds writes to the
fixed offsets[] array.

Reject payloads smaller than the config struct and channel counts
outside the supported range before computing mic_cnt, and bound the
offsets[] index inside the loop.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
The KP_BUF_CFG_FM_MODULE large-config path cast the host payload to
struct kpb_task_params and iterated dev_ids[] for number_of_modules
entries without checking it against the declared payload length, so a
number_of_modules larger than the payload caused out-of-bounds reads.

Verify the payload covers the header and all declared dev_ids[]
entries before processing the list.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
prepare_fmt_modules_list() populates kpb_list_item[], device_list[]
and modules_list_item[] entries as it walks the module list. On any
mid-loop failure it returned without undoing those entries, while the
caller had already cleared the previous list, leaving a
half-configured Fast Mode Task list with stale component references.

Roll back the touched entries via clear_fmt_modules_list() on the
error path, and add a defensive bound check on outpin_idx.

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.

3 participants