llext: userspace: clear cold segment descriptors when sections are ab… - #11159
Open
kv2019i wants to merge 1 commit into
Open
llext: userspace: clear cold segment descriptors when sections are ab…#11159kv2019i wants to merge 1 commit into
kv2019i wants to merge 1 commit into
Conversation
…sent
llext_manager_rm_mod_domain() removes the .cold and .coldrodata memory
partitions of a module from its domain if the corresponding
mctx->segment[] descriptor has a non-zero address. Those descriptors are
only ever populated by llext_manager_add_mod_domain() when the module
actually contains a .cold / .coldrodata section.
The module context array is allocated with rmalloc() (non-zeroing) and
llext_manager_mod_init() initialises every field except the segment[]
array. The LIB_MANAGER_TEXT/RODATA/DATA/BSS descriptors are filled in
during linking, but LIB_MANAGER_COLD / LIB_MANAGER_COLDRODATA are left
holding uninitialised heap data for any module that has no such section.
As a result, when such a module is freed, rm_mod_domain() sees a garbage
non-zero address and tries to remove a partition that was never added:
<err> os.k_mem_domain_remove_partition: no matching partition found
<err> lib_manager.llext_manager_rm_mod_domain: failed to remove
.coldrodata memory partition: -2
Reproduced at end-of-stream of a DMIC capture (arecord -Dhw:0,4), whose
EQIIR / TDFB / DRC modules carry no .coldrodata section.
Make add_mod_domain() the sole owner of these descriptors: explicitly
zero them when the section is absent, so rm_mod_domain() only ever
removes partitions that were really added.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
kv2019i
requested review from
dbaluta,
lbetlej,
lgirdwood,
mmaka1 and
plbossart
as code owners
September 2, 2026 13:02
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped to correctly initializing two segment descriptors and aligns with the teardown logic’s “remove only if addr is non-zero” contract.
Pull request overview
This PR fixes a userspace memory-domain teardown bug in the LLEXT library manager by ensuring .cold / .coldrodata segment descriptors are deterministically cleared when those sections are absent, preventing llext_manager_rm_mod_domain() from attempting to remove partitions that were never added.
Changes:
- Explicitly zero
mctx->segment[LIB_MANAGER_COLD]when the module has no.coldsection. - Explicitly zero
mctx->segment[LIB_MANAGER_COLDRODATA]when the module has no.coldrodatasection.
File summaries
| File | Description |
|---|---|
| src/library_manager/llext_manager.c | Clears .cold/.coldrodata segment descriptors when sections are absent to avoid erroneous partition removals during domain teardown. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
…sent
llext_manager_rm_mod_domain() removes the .cold and .coldrodata memory partitions of a module from its domain if the corresponding mctx->segment[] descriptor has a non-zero address. Those descriptors are only ever populated by llext_manager_add_mod_domain() when the module actually contains a .cold / .coldrodata section.
The module context array is allocated with rmalloc() (non-zeroing) and llext_manager_mod_init() initialises every field except the segment[] array. The LIB_MANAGER_TEXT/RODATA/DATA/BSS descriptors are filled in during linking, but LIB_MANAGER_COLD / LIB_MANAGER_COLDRODATA are left holding uninitialised heap data for any module that has no such section.
As a result, when such a module is freed, rm_mod_domain() sees a garbage non-zero address and tries to remove a partition that was never added:
os.k_mem_domain_remove_partition: no matching partition found
lib_manager.llext_manager_rm_mod_domain: failed to remove
.coldrodata memory partition: -2
Reproduced at end-of-stream of a DMIC capture (arecord -Dhw:0,4), whose EQIIR / TDFB / DRC modules carry no .coldrodata section.
Make add_mod_domain() the sole owner of these descriptors: explicitly zero them when the section is absent, so rm_mod_domain() only ever removes partitions that were really added.