Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/ipc/ipc4/handler-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,17 +1005,22 @@ __cold int ipc4_set_vendor_config_module_instance(struct comp_dev *dev,
while ((const uint8_t *)tlv < end_offset) {
size_t remaining = (size_t)(end_offset - (const uint8_t *)tlv);

/* the TLV header must fit in the payload before any of
* its fields are read, else the header read itself runs
* past the end of the hostbox
*/
if (remaining < sizeof(struct sof_tlv))
return IPC4_INVALID_REQUEST;

/* check for invalid length */
if (!tlv->length)
return IPC4_INVALID_CONFIG_DATA_LEN;

/* Validate TLV header + value fits within remaining
* payload to prevent OOB access and pointer wraparound
* on 32-bit arithmetic (CWE-190). Split into two checks
* to avoid overflow in the size_t addition itself.
/* Validate the value fits within the remaining payload
* to prevent OOB access and pointer wraparound on
* 32-bit arithmetic (CWE-190).
*/
if (remaining < sizeof(struct sof_tlv) ||
tlv->length > remaining - sizeof(struct sof_tlv))
if (tlv->length > remaining - sizeof(struct sof_tlv))
return IPC4_INVALID_REQUEST;

ret = drv->ops.set_large_config(dev, tlv->type, init_block,
Expand Down
Loading