Repository navigation
audio: copier: bound ipcgtw SET_DATA read to the message window - #11400
Open
Shrusti-pk wants to merge 1 commit into
Open
Shrusti-pk wants to merge 1 commit into
Shrusti-pk wants to merge 1 commit into
Conversation
copier_ipcgtw_process() handles the IPC4 IPCGATEWAY_CMD. The SET_DATA case sets data_size to MIN(cmd->extension.r.data_size, sink_get_free_size(sink)) and then reads that many bytes from in->payload (MAILBOX_HOSTBOX_BASE + 4) into the gateway sink with sink_copy_bytes_from_linear(), after a dcache invalidate over the same span. Both inputs are host controlled. extension.r.data_size is a 30-bit field in the gateway command, and the sink free size derives from the gateway buffer whose size comes from blob->buffer_size in the gateway config and is applied with buffer_set_size(), so it can be much larger than the fixed inbox window. When both exceed the window the copy reads past the MAILBOX_HOSTBOX region and feeds adjacent memory into the audio stream. The sibling IPC4_IPCGWCMD_GET_DATA case in the same function already caps data_size at SOF_IPC_MSG_MAX_SIZE - 4. Apply the same cap before the sink free-size MIN in the SET_DATA case. Signed-off-by: Shrushti P K <shrusthi@labs.digiscrypt.com>
Collaborator
|
Can one of the admins verify this patch?
|
lgirdwood
approved these changes
Nov 4, 2026
Collaborator
|
test this please |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Out-of-bounds read in the IPC4 gateway SET_DATA path
copier_ipcgtw_process()setsdata_size = MIN(cmd->extension.r.data_size, sink_get_free_size(sink))and then reads that many bytes from the inbox window (in->payload, atMAILBOX_HOSTBOX_BASE + 4) into the gateway sink. Both inputs are host controlled:extension.r.data_sizeis a 30-bit field in the gateway command, and the sink free size comes from the gateway buffer whose size is taken fromblob->buffer_sizein the gateway config and applied withbuffer_set_size(), so it can be much larger than the fixed inbox window. A SET_DATA with a large count then reads (and dcache-invalidates) past theMAILBOX_HOSTBOXregion and copies adjacent memory into the audio stream. TheIPC4_IPCGWCMD_GET_DATAcase right above already caps atSOF_IPC_MSG_MAX_SIZE - 4; SET_DATA now does the same before the sink free-size MIN.Reproduced under ASan with the SET_DATA bound logic: a 0x1000 inbox window and host
data_size0x10000 gives a heap-buffer-overflow READ of 65536 bytes 0 bytes past the 4096-byte region; with the cap the read is bounded to 4092 bytes and completes cleanly.