Skip to content

Commit 0d9b5ec

Browse files
kv2019ilgirdwood
authored andcommitted
ipc: ipc4: harden ipc_comp_disconnect() against invalid sink
Check the provided sink actually is connected to the buffer, before proceeding to free the buffer. This protects against an invalid IPC sent by the host. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent c72905e commit 0d9b5ec

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/ipc/ipc4/helper.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,18 @@ __cold int ipc_comp_disconnect(struct ipc *ipc, ipc_pipe_comp_connect *_connect)
920920
if (!buffer)
921921
return IPC4_INVALID_RESOURCE_ID;
922922

923+
/*
924+
* The buffer was located on the source's consumer list, but the sink was
925+
* resolved solely from the host-supplied dst_module_id/dst_instance_id.
926+
* Make sure the buffer is actually connected to that sink, otherwise an
927+
* incorrect dst would leave the real sink bound to a buffer we are about
928+
* to free, while unbinding an unrelated component instead.
929+
*/
930+
if (comp_buffer_get_sink_component(buffer) != sink) {
931+
tr_err(&ipc_tr, "buffer %#x is not connected to sink %#x", buffer_id, sink_id);
932+
return IPC4_INVALID_RESOURCE_ID;
933+
}
934+
923935
/*
924936
* Disconnect and unbind buffer from source/sink components and continue to free the buffer
925937
* even in case of errors. Block LL processing during disconnect and unbinding to prevent

0 commit comments

Comments
 (0)