Skip to content

llext-manager: reject manifests with no module segments - #11286

Open
tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/llext/fix/reject_manifests_with_no_modules
Open

tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/llext/fix/reject_manifests_with_no_modules

Conversation

@tmleman

@tmleman tmleman commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

The existing overflow check only rejects a module entry array that runs past the image, so a manifest describing zero distinct text segments passes it and leaves n_mod == 0. The subsequent ctx->mod[n_mod - 1].n_mod store then writes immediately before the allocation.

Bail out with -EINVAL once the modules have been counted and none were found.

Found by clang-analyzer-security.ArrayBound.

Assisted-by: Copilot:claude-opus-5 clang-tidy

Copilot AI balanced review requested due to automatic review settings October 8, 2026 10:09

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.

🟢 Approval recommended

The guard prevents invalid indexing, preserves valid-manifest behavior, and uses existing error propagation.

0 open findings

What changed in this PR

Prevents out-of-bounds indexing in the loadable-library manager when a manifest contains no distinct module segments.

Changes:

  • Rejects zero-module manifests with -EINVAL before accessing module storage.
  • Logs the rejected manifest’s entry count and documents the guard.
File Description
src/​library_manager/​llext_manager.c Adds a guard against zero-module manifests.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

The existing overflow check only rejects a module entry array that runs past
the image, so a manifest describing zero distinct text segments passes it and
leaves n_mod == 0. The subsequent ctx->mod[n_mod - 1].n_mod store then writes
immediately before the allocation.

Bail out with -EINVAL once the modules have been counted and none were found.

Found by clang-analyzer-security.ArrayBound.

Assisted-by: Copilot:claude-opus-5 clang-tidy
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
@intel-sofci

Copy link
Copy Markdown

PR 11286: test results

Run date: 2026-10-08 12:02 UTC

Tested commit: 3415598cc7961daccadc62acb350c5b13c7b6140

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please see inline

* A manifest with no distinct module segments would leave n_mod == 0,
* making the ctx->mod[n_mod - 1] accesses below index out of bounds
*/
if (!n_mod) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the change is good given some malloc() implementations do return a pointer, but I think the comment + commitmsg are misleading as SOF allocated do return NULL so if n_mod is zero, this function will return -ENOMEM on line 568. I think explicit check is still better, but please correct the commit and maybe reduce the inline comments. This is self-explanatory.

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.

4 participants