Skip to content

Commit c351193

Browse files
abonislawskikv2019i
authored andcommitted
module_adapter: ipc4: validate pin counts against IPC4 maximum
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>
1 parent 818713d commit c351193

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/audio/module_adapter/module_adapter_ipc4.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <sof/ut.h>
2222
#include <rtos/interrupt.h>
2323
#include <rtos/symbol.h>
24+
#include <ipc4/base_fw.h>
2425
#include <limits.h>
2526
#include <stdint.h>
2627

@@ -162,6 +163,9 @@ int module_adapter_init_data(struct comp_dev *dev,
162163
+ (n_out * sizeof(*dst->output_pins));
163164

164165
if (cfgsz == (sizeof(*cfg) + pinsz)) {
166+
if (n_in > IPC4_MAX_SRC_QUEUE || n_out > IPC4_MAX_DST_QUEUE)
167+
return -EINVAL;
168+
165169
dst->nb_input_pins = n_in;
166170
dst->nb_output_pins = n_out;
167171
dst->input_pins = sof_heap_alloc(dev->mod->priv.resources.alloc->heap,

0 commit comments

Comments
 (0)