Skip to content

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

Merged
lgirdwood merged 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/llext/fix/reject_manifests_with_no_modules
Oct 14, 2026
Merged

lgirdwood merged 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.

@intel-sofci

intel-sofci commented Oct 8, 2026 •

Copy link
Copy Markdown

PR 11286: test results

Run date: 2026-10-14 11:27 UTC

Tested commit: aa2341659cced0d1ecf66eed6100d942b30c3ab3

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

kv2019i
kv2019i previously requested changes Oct 9, 2026

@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

Comment thread src/library_manager/llext_manager.c

@softwarecki softwarecki 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.

I agree that inline comment is superfluous.

@tmleman
tmleman force-pushed the topic/upstream/pr/llext/fix/reject_manifests_with_no_modules branch 3 times, most recently from 9607d0a to aa23416 Compare October 14, 2026 09:38
@tmleman
tmleman requested a review from kv2019i October 14, 2026 09:38
Treat zero modules as an invalid manifest. While SOF rmalloc() returns
NULL for a zero-size allocation, causing the old code to return -ENOMEM,
this validation returns the appropriate -EINVAL error before allocating
and prevents later n_mod - 1 indexes from depending on allocator behavior.

Found by clang-analyzer-security.ArrayBound.

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

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
@lgirdwood
lgirdwood merged commit d59ba32 into thesofproject:main Oct 14, 2026
47 of 48 checks passed
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.

6 participants