Skip to content

Commit e279680

Browse files
lrgirdwokv2019i
authored andcommitted
copier: validate ipc gateway config length covers the blob
The IPC gateway path read a config blob from the gateway data without checking the declared config length covered it, over-reading the mailbox tail. Reject a config length too small for the gateway config header and blob. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 4764a4f commit e279680

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/audio/copier/copier_ipcgtw.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,20 @@ __cold int copier_ipcgtw_create(struct processing_module *mod,
223223
return -EINVAL;
224224
}
225225

226+
/* config_length is in dwords; require enough dwords to cover the
227+
* gateway config header and the blob read below. Compare dword counts
228+
* (rather than scaling config_length by 4) so a large host-supplied
229+
* value cannot overflow the multiplication on 32-bit size_t.
230+
*/
231+
if (gtw_cfg->config_length <
232+
SOF_DIV_ROUND_UP(sizeof(struct ipc4_gateway_config_data) +
233+
sizeof(struct ipc4_ipc_gateway_config_blob),
234+
sizeof(uint32_t))) {
235+
comp_err(dev, "ipc4_gateway_config_data too small: %u",
236+
gtw_cfg->config_length);
237+
return -EINVAL;
238+
}
239+
226240
cd->ipc_gtw = true;
227241

228242
/* The IPC gateway is treated as a host gateway */

0 commit comments

Comments
 (0)