Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The size check requires worst-case capacity rather than the actual serialized reply size. With the default 64 Intel codec slots and both clock tuples enabled, it requires 572 bytes even though an empty-codec reply needs only 304, so a valid vendor request with a 512-byte buffer fails with IPC4_OUT_OF_MEMORY.
1 open issue
What changed in this PR
Hardens IPC4 vendor configuration replies against integer overflow in host-controlled length checks.
Changes:
- Replaces length addition with remaining-capacity checks.
- Adds worst-case FW_CONFIG size validation and vendor-specific size bounds.
| File | Description |
|---|---|
src/kernel/audio/base_fw.c |
Adds a worst-case reply capacity guard. |
src/ipc/ipc4/handler-user.c |
Makes vendor reply length checks overflow-safe. |
src/include/ipc4/base_fw_vendor.h |
Defines vendor configuration size bounds. |
Review effort: Balanced
PR 11609: test resultsRun date: 2026-12-04 15:11 UTC Tested commit: 6a907c14ab09aea07105c8c1554f874467329f1c |
|
@tmleman are you able to resolve copilot comments. Thanks ! |
b0bcf39 to
6a907c1
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The IPC capacity check still allows HW_CONFIG to overflow comp_data after preceding SYSTEM_TIME entries because the getter does not enforce remaining buffer capacity before writing; checking its returned length afterward is too late. Separately, with CONFIG_SOF_ZEPHYR_NO_SOF_CLOCK enabled, the base firmware capacity check overestimates the serialized reply by 24 bytes and rejects a host max_length that exactly fits the complete reply.
2 open issues
1 resolved since last review
Review effort: Balanced
| if (produced_data + sizeof(*output_tlv) > MAILBOX_DSPBOX_SIZE || | ||
| input_tl[i].max_length > | ||
| MAILBOX_DSPBOX_SIZE - produced_data - sizeof(*output_tlv)) { |
| sizeof(struct sof_tlv) + sizeof(uint32_t)) | ||
|
|
||
| /* Upper bound of the uint32_t value tuples basefw_config() writes. */ | ||
| #define BASEFW_CONFIG_U32_TUPLES_MAX 17 |
ipc4_get_vendor_config_module_instance() rejects a TL when
produced_data + sizeof(struct sof_tlv) + max_length exceeds
MAILBOX_DSPBOX_SIZE. max_length comes straight from the host and the
sum is a 32-bit size_t on the DSP, so max_length = 0xffffffff wraps the
sum to produced_data + 7 and the check always passes. Each getter is
then told it has 0xffffffff bytes and the loop keeps appending replies
past the end of ipc->comp_data (SOF_IPC_MSG_MAX_SIZE bytes).
Found by the IPC4 fuzzer (ASan): 38 BaseFW TLs of
{IPC4_FW_CONFIG, 0xffffffff} write at comp_data + 4096 on the 15th
basefw_config() call.
Check that the header fits first, then compare max_length against the
space left instead of adding it.
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
basefw_config() writes the whole IPC4_FW_CONFIG tuple list (about
280 bytes) without looking at *data_offset. Through a
VENDOR_CONFIG_PARAM get, data points after earlier TLV replies inside
ipc->comp_data and *data_offset is the host max_length, narrowed to the
room that is left. A host sending many {IPC4_FW_CONFIG, 0} TLs passes
the vendor loop bound on every TL while each reply is ~288 bytes, so
the 15th reply runs past the end of the 4096 byte comp_data.
Add BASEFW_CONFIG_FIXED_SIZE_MAX, the worst-case size of the fixed
tuples including the vendor tuples (new BASEFW_VENDOR_FW_CONFIG_SIZE_MAX).
Build the nested IPC4_FW_SOF_INFO tuple once up front, so that its actual
size, not the all-codec-slots worst case, is added to the bound, and the
checked size is the size that gets written. Refuse with
IPC4_OUT_OF_MEMORY when MIN(*data_offset, SOF_IPC_MSG_MAX_SIZE) is
smaller, as done for the extended perf data reply.
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>


ipc4_get_vendor_config_module_instance() rejects a TL when produced_data + sizeof(struct sof_tlv) + max_length exceeds MAILBOX_DSPBOX_SIZE. max_length comes straight from the host and the sum is a 32-bit size_t on the DSP, so max_length = 0xffffffff wraps the sum to produced_data + 7 and the check always passes. Each getter is then told it has 0xffffffff bytes and the loop keeps appending replies past the end of ipc->comp_data (SOF_IPC_MSG_MAX_SIZE bytes).
Found by the IPC4 fuzzer (ASan): 38 BaseFW TLs of {IPC4_FW_CONFIG, 0xffffffff} write at comp_data + 4096 on the 15th basefw_config() call.
Check that the header fits first, then compare max_length against the space left instead of adding it.