Skip to content

Commit bed995f

Browse files
tmlemanlgirdwood
authored andcommitted
audio: base_fw: validate dma control payload length before subtract
basefw_dma_control() computes data_size = data_offset - sizeof(struct ipc4_dma_control) where data_offset is the host-supplied payload length. When data_offset is smaller than the header the unsigned subtraction wraps to a huge value that passes the length check and is forwarded as the payload size, leading to an out-of-bounds read. Reject data_offset values smaller than the fixed header before the subtraction. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent 2575428 commit bed995f

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/audio/base_fw.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,13 @@ __cold static int basefw_dma_control(bool first_block, bool last_block, uint32_t
770770
}
771771

772772
dma_control = (struct ipc4_dma_control *)data;
773+
774+
/* data_offset must cover the fixed header before computing the payload size */
775+
if (data_offset < sizeof(struct ipc4_dma_control)) {
776+
tr_err(&ipc_tr, "DMA Control message too short: %u", data_offset);
777+
return IPC4_ERROR_INVALID_PARAM;
778+
}
779+
773780
data_size = data_offset - sizeof(struct ipc4_dma_control);
774781

775782
if (data_size < (dma_control->config_length * sizeof(uint32_t))) {

0 commit comments

Comments
 (0)