Skip to content

module_adapter: ipc4: validate pin counts against IPC4 maximum#10787

Open
abonislawski wants to merge 3 commits into
thesofproject:mainfrom
abonislawski:fix/module-adapter-max-pins
Open

module_adapter: ipc4: validate pin counts against IPC4 maximum#10787
abonislawski wants to merge 3 commits into
thesofproject:mainfrom
abonislawski:fix/module-adapter-max-pins

Conversation

@abonislawski
Copy link
Copy Markdown
Member

Reject IPC4 module init payloads where nb_input_pins or nb_output_pins
exceed the protocol maximum (IPC4_MAX_SRC_QUEUE / IPC4_MAX_DST_QUEUE = 8).

The existing cfgsz equality check ensures the immediate pointer
arithmetic is in-bounds, but it does not prevent unsupported pin counts
from being stored in dst->nb_input_pins / dst->nb_output_pins and used
by downstream module code. Add explicit upper-bound validation before
computing pinsz, matching the IPC4 ABI contract advertised via
IPC4_MAX_MODULE_PIN_COUNT_FW_CFG.

Remove the repeated 'count' in the IPC4_MAX_SRC_QUEUE comment.

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Add IPC4_MAX_DST_QUEUE (value 8) as the symmetric counterpart to
IPC4_MAX_SRC_QUEUE, representing the maximum destination/output pin
queue count supported by the IPC4 protocol.

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Copilot AI review requested due to automatic review settings May 18, 2026 09:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds upper-bound validation for IPC4 module init pin counts so that values exceeding the IPC4 protocol maximum (8) are rejected before being stored and used downstream, complementing the existing exact cfgsz check.

Changes:

  • Define new IPC4_MAX_DST_QUEUE constant (8) and fix a duplicated word ("count count") in the existing IPC4_MAX_SRC_QUEUE comment.
  • Validate nb_input_pins/nb_output_pins against IPC4_MAX_SRC_QUEUE/IPC4_MAX_DST_QUEUE in module_adapter_init_data() and return -EINVAL if exceeded.
  • Include <ipc4/base_fw.h> in module_adapter_ipc4.c for the new constants.

Reviewed changes

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

File Description
src/include/ipc4/base_fw.h Adds IPC4_MAX_DST_QUEUE macro and corrects a comment typo.
src/audio/module_adapter/module_adapter_ipc4.c Includes base_fw.h and rejects pin counts exceeding IPC4 maxima before computing pinsz.

Reject IPC4 module init payloads where nb_input_pins or nb_output_pins
exceed the protocol maximum (IPC4_MAX_SRC_QUEUE / IPC4_MAX_DST_QUEUE = 8).

The existing cfgsz equality check ensures the immediate pointer
arithmetic is in-bounds, but it does not prevent unsupported pin counts
from being stored in dst->nb_input_pins / dst->nb_output_pins and used
by downstream module code. Add explicit upper-bound validation before
computing pinsz, matching the IPC4 ABI contract advertised via
IPC4_MAX_MODULE_PIN_COUNT_FW_CFG.

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
@abonislawski abonislawski force-pushed the fix/module-adapter-max-pins branch from 0b214bb to bb16604 Compare May 18, 2026 11:02
@abonislawski
Copy link
Copy Markdown
Member Author

Update: I moved the check two lines down. It was accidentally in the wrong place and this was caught by the testbench and CI.

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.

4 participants