Skip to content

Commit f2712cb

Browse files
committed
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 0d5790c commit f2712cb

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/audio/copier/copier_ipcgtw.c

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

226+
/* config_length is in dwords; make sure it covers the gateway config
227+
* header and the full blob read below before dereferencing it
228+
*/
229+
if ((size_t)gtw_cfg->config_length * sizeof(uint32_t) <
230+
sizeof(struct ipc4_gateway_config_data) +
231+
sizeof(struct ipc4_ipc_gateway_config_blob)) {
232+
comp_err(dev, "ipc4_gateway_config_data too small: %u",
233+
gtw_cfg->config_length);
234+
return -EINVAL;
235+
}
236+
226237
cd->ipc_gtw = true;
227238

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

0 commit comments

Comments
 (0)