Skip to content

Commit a660742

Browse files
committed
audio: data_blob: bound blob read against data_size
comp_data_blob_get_cmd() advanced data_pos by the host-controlled num_elems each fragment with no check against the blob size, so a fragmented bytes-get could read past the blob and leak adjacent DSP heap to the host. Reject reads where data_pos or num_elems exceed data_size. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent 6d5cf82 commit a660742

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/audio/data_blob.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,18 @@ int comp_data_blob_get_cmd(struct comp_data_blob_handler *blob_handler,
628628
return -EINVAL;
629629
}
630630

631+
/* Bound data_pos against data_size: host-controlled num_elems
632+
* advances it per fragment and could leak adjacent heap.
633+
*/
634+
if (blob_handler->data_pos >= blob_handler->data_size ||
635+
cdata->num_elems > blob_handler->data_size - blob_handler->data_pos) {
636+
comp_err(blob_handler->dev,
637+
"out of bounds read: pos %u elems %u size %u",
638+
blob_handler->data_pos, cdata->num_elems,
639+
blob_handler->data_size);
640+
return -EINVAL;
641+
}
642+
631643
/* copy required size of data */
632644
ret = memcpy_s(cdata->data->data, size,
633645
(char *)blob_handler->data + blob_handler->data_pos,

0 commit comments

Comments
 (0)