ipc: ipc4: harden ipc_comp_disconnect() against invalid sink#10874
Merged
lgirdwood merged 1 commit intoJun 12, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens ipc_comp_disconnect() (IPC4 unbind) by validating that the host-provided sink actually matches the buffer being disconnected, preventing an invalid IPC message from causing the firmware to unbind/free the wrong connection.
Changes:
- Add a verification step ensuring the located buffer is connected to the resolved sink before proceeding with disconnect/free.
- Emit an error and return
IPC4_INVALID_RESOURCE_IDwhen the sink does not match the buffer’s actual connection.
Comment on lines
+930
to
+942
| bool sink_connected = false; | ||
|
|
||
| comp_dev_for_each_producer(sink, buf) { | ||
| if (buf == buffer) { | ||
| sink_connected = true; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (!sink_connected) { | ||
| tr_err(&ipc_tr, "buffer %#x is not connected to sink %x", buffer_id, sink_id); | ||
| return IPC4_INVALID_RESOURCE_ID; | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
Ok, this is better, used the alternative in V2.
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>
ddedd0a to
a1d6024
Compare
Collaborator
Author
|
V2:
|
lgirdwood
approved these changes
Jun 11, 2026
tmleman
reviewed
Jun 12, 2026
Comment on lines
920
to
+933
| if (!buffer) | ||
| return IPC4_INVALID_RESOURCE_ID; | ||
|
|
||
| /* | ||
| * The buffer was located on the source's consumer list, but the sink was | ||
| * resolved solely from the host-supplied dst_module_id/dst_instance_id. | ||
| * Make sure the buffer is actually connected to that sink, otherwise an | ||
| * incorrect dst would leave the real sink bound to a buffer we are about | ||
| * to free, while unbinding an unrelated component instead. | ||
| */ | ||
| if (comp_buffer_get_sink_component(buffer) != sink) { | ||
| tr_err(&ipc_tr, "buffer %#x is not connected to sink %#x", buffer_id, sink_id); | ||
| return IPC4_INVALID_RESOURCE_ID; | ||
| } |
Contributor
There was a problem hiding this comment.
Can we do it in a single IF statement?
if (!buffer || comp_buffer_get_sink_component(buffer) != sink) {
tr_err(&ipc_tr, "buffer %#x is not connected to sink %#x", buffer_id, sink_id);
return IPC4_INVALID_RESOURCE_ID;
}
Collaborator
There was a problem hiding this comment.
that would make the comment placement more difficult :-)
Member
There was a problem hiding this comment.
priority is the fix today, there will be a chance to optimize/refactor later.
lyakh
approved these changes
Jun 12, 2026
abonislawski
approved these changes
Jun 12, 2026
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.
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.