Skip to content

Commit 0666910

Browse files
author
Jyri Sarha
committed
ipc4: large_config: fix data_off_size underflow on init-only block
ipc4_set_vendor_config_module_instance() only validated data_off_size in the bursted-config path (init_block && final_block). The else path with init_block == 1 && final_block == 0 unconditionally executed: data += sizeof(struct sof_tlv); data_off_size -= sizeof(struct sof_tlv); data_off_size is a host-controlled 20-bit field taken straight from the IPC message. When it is smaller than sizeof(struct sof_tlv) (8) the subtraction underflows and wraps to a value close to 0xFFFFFFFF, which is then forwarded as the length to the module's set_large_config() handler. The actual backing buffer is only the MAILBOX_HOSTBOX_SIZE mailbox, so a compromised host could trigger out-of-bounds reads of DSP SRAM (and possible corruption depending on the target module) by sending MOD_LARGE_CONFIG_SET with init_block=1, final_block=0 and data_off_size < 8. Hoist the existing "data_off_size < sizeof(struct sof_tlv) || data_off_size > MAILBOX_HOSTBOX_SIZE" bounds check to the top of the function so it runs for every entry, before any pointer or size arithmetic. The duplicate check in the bursted-config branch is removed as it is now covered by the hoisted one. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 3f7738d commit 0666910

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/ipc/ipc4/handler-user.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,15 +1109,13 @@ __cold static int ipc4_set_vendor_config_module_instance(struct comp_dev *dev,
11091109

11101110
assert_can_be_cold();
11111111

1112+
/* Validate the host-controlled payload size before any use or arithmetic. */
1113+
if (data_off_size < sizeof(struct sof_tlv) || data_off_size > MAILBOX_HOSTBOX_SIZE)
1114+
return IPC4_INVALID_CONFIG_DATA_STRUCT;
1115+
11121116
/* Old FW comment: bursted configs */
11131117
if (init_block && final_block) {
11141118
const struct sof_tlv *tlv = (struct sof_tlv *)data;
1115-
/* if there is no payload in this large config set
1116-
* (4 bytes type | 4 bytes length=0 | no value)
1117-
* we do not handle such case
1118-
*/
1119-
if (data_off_size < sizeof(struct sof_tlv) || data_off_size > MAILBOX_HOSTBOX_SIZE)
1120-
return IPC4_INVALID_CONFIG_DATA_STRUCT;
11211119

11221120
/* ===Iterate over payload===
11231121
* Payload can have multiple sof_tlv structures inside,

0 commit comments

Comments
 (0)