Repository navigation
audio: module_adapter: cap connected buffers at MODULE_MAX_CONNECTIONS - #11417
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
struct processing_module holds CONFIG_MODULE_MAX_CONNECTIONS entries in sinks[] and sources[], but the module adapter stores one entry per connected buffer without bounding the index. On IPC4, module_adapter_update_sinks_sources() runs from module_adapter_bind(), and ipc4_comp_connect() connects a new buffer for every MOD_BIND, so a ninth bind on one side of a module writes sinks[8] over sources[0] and further binds run past the processing_module allocation. On IPC3, module_adapter_sink_src_prepare() does the same at prepare time. The connection count checks in module_adapter_prepare() only covered the audio_stream path removed in a42e9b7, and the max_sources and max_sinks fields are no longer read. Refuse a bind in module_adapter_bind() that brings the buffers connected on that side above CONFIG_MODULE_MAX_CONNECTIONS, and fail module_adapter_sink_src_prepare() with -EINVAL instead of writing past the arrays. A refusal on the sink side goes through the e_sink_bind path of ipc4_comp_connect(), which unbinds the source while the buffer is still connected. The source then refreshes its sinks[] with the buffer that is freed right after. Disconnect first, as ipc4_comp_disconnect() does.
Shrusti-pk
requested review from
dbaluta,
kv2019i,
lbetlej,
lgirdwood,
mmaka1,
plbossart and
ranj063
as code owners
November 7, 2026 06:17
Collaborator
|
Can one of the admins verify this patch?
|
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.
module_adapter keeps one
sinks[]/sources[]slot per connected buffer, but nothing stops a module from having more buffers thanCONFIG_MODULE_MAX_CONNECTIONS(8):ipc4_comp_connect()connects a new buffer for every MOD_BIND andmodule_adapter_update_sinks_sources()then stores all of them. The ninth bind on one side writessinks[8]oversources[0], later ones run off the end ofstruct processing_module. IPC3module_adapter_sink_src_prepare()does the same at prepare. The count checks inmodule_adapter_prepare()only covered the audio_stream path removed in a42e9b7.CONFIG_LIBRARYlibsof built with ASan and driven throughipc_cmd()the way sof-testbench4 does it. Create 16 gain instances and bind gain.1..15 into gain.0: the 14th MOD_BIND gives a heap-buffer-overflow WRITE of size 8 inmodule_adapter_update_sinks_sources()(module_adapter_bind()<-ipc4_comp_connect()<-ipc4_bind_module_instance()), 0 bytes after the 448-byteprocessing_module. The IPC3 prepare overflows the same way in the cmocka build with 14 sources.e_sink_bindpath, which unbound the source while the buffer was still connected, so the source'ssinks[]kept the buffer freed right after (ASan heap-use-after-free on the next use with only the bind check applied).mixout_bind()refusing a ninth mixin already takes that path. It now disconnects first, asipc4_comp_disconnect()does.With the patch the ninth bind is refused with IPC4_INVALID_RESOURCE_STATE on either side and the refused source is left with no stale sink. Binds up to 8 per side are unchanged, the IPC4 library build (
-Wall -Werror) is clean and the cmocka unit tests pass.