Skip to content

lib_manager: bound build info offset and check resume allocation#10931

Open
lgirdwood wants to merge 2 commits into
thesofproject:mainfrom
lgirdwood:fix-library-manager
Open

lib_manager: bound build info offset and check resume allocation#10931
lgirdwood wants to merge 2 commits into
thesofproject:mainfrom
lgirdwood:fix-library-manager

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Two robustness fixes in the library manager:

  • bound the manifest-supplied TEXT segment file_offset against the library
    image size before deriving the build-info pointer, so a crafted manifest
    cannot read outside the library buffer
  • check the context allocation on the IMR/DRAM resume path before writing
    through it (NULL dereference under memory pressure otherwise)

lrgirdwo added 2 commits June 11, 2026 14:40
The build info pointer was derived from a manifest-supplied text segment
offset without bounds, so a crafted manifest could read outside the
library buffer. Validate the offset against the library image size
before dereferencing and fail the module type lookup otherwise.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The resume path allocated a library context and immediately wrote
through it without a NULL check, crashing under memory pressure. Check
the allocation and fail the restore gracefully.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Copilot AI review requested due to automatic review settings June 16, 2026 14:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Hardens library manager restore and module parsing paths by adding bounds/NULL checks to prevent OOB reads and NULL dereferences under adverse conditions.

Changes:

  • Add NULL-check for resume-path context allocation before dereferencing.
  • Validate manifest-supplied TEXT segment file_offset against the library image size before using it to derive build_info.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/library_manager/llext_manager_dram.c Adds allocation failure handling on DRAM/IMR resume path.
src/library_manager/lib_manager.c Adds bounds check for TEXT file_offset before dereferencing derived build-info pointer.

Comment on lines +583 to +589
const size_t lib_size = (size_t)desc->header.preload_page_count * PAGE_SZ;
const uint32_t text_off = mod->segment[SOF_MAN_SEGMENT_TEXT].file_offset;

if (text_off > lib_size || lib_size - text_off < sizeof(*build_info)) {
tr_err(&lib_manager_tr, "Invalid TEXT file_offset %u", text_off);
return MOD_TYPE_INVALID;
}
Comment on lines +586 to +589
if (text_off > lib_size || lib_size - text_off < sizeof(*build_info)) {
tr_err(&lib_manager_tr, "Invalid TEXT file_offset %u", text_off);
return MOD_TYPE_INVALID;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants