Skip to content

Commit 121da6d

Browse files
author
Jyri Sarha
committed
ipc4: chain_dma: fix use-after-free on chain DMA deallocate
ipc4_process_chain_dma() called ipc4_chain_dma_state() and then, on the deallocate path (allocate == 0 && enable == 0), unconditionally executed list_item_del(&cdma_comp->list). However, on that same deallocate path ipc4_chain_dma_state() already unlinks the matching ipc_comp_dev from ipc->comp_list and frees it with rfree(): list_item_del(&icd->list); rfree(icd); Since icd is the same object as cdma_comp, the subsequent list_item_del(&cdma_comp->list) in the caller dereferenced and wrote to already-freed memory (prev->next / next->prev), a use-after-free. With heap grooming a host sending GLB_CHAIN_DMA with allocate=0/enable=0 on an existing chain could turn this into controlled heap corruption. The unlink-before-free is already handled correctly by ipc4_chain_dma_state(), so the duplicate list_item_del() in the caller is both redundant and unsafe. Remove it. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 0666910 commit 121da6d

1 file changed

Lines changed: 0 additions & 3 deletions

File tree

src/ipc/ipc4/handler-user.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,6 @@ __cold static int ipc4_process_chain_dma(struct ipc4_message_request *ipc4)
611611
if (ret < 0)
612612
return IPC4_INVALID_CHAIN_STATE_TRANSITION;
613613

614-
if (!cdma.primary.r.allocate && !cdma.primary.r.enable)
615-
list_item_del(&cdma_comp->list);
616-
617614
return IPC4_SUCCESS;
618615
#else
619616
return IPC4_UNAVAILABLE;

0 commit comments

Comments
 (0)