Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/library_manager/lib_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,26 @@ static enum buildinfo_mod_type lib_manager_get_module_type(const struct sof_man_
const struct sof_module_api_build_info *const build_info =
(const struct sof_module_api_build_info *)((const char *)desc -
SOF_MAN_ELF_TEXT_OFFSET + mod->segment[SOF_MAN_SEGMENT_TEXT].file_offset);
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;

/*
* llext modules store build info structure in separate section which is not accessible now.
*/
if (module_is_llext(mod))
return MOD_TYPE_LLEXT;

/*
* build_info is derived from a manifest-supplied file_offset; bound it
* against the library image size before dereferencing so a crafted
* offset cannot read outside the library buffer.
*/
if (text_off > lib_size || lib_size - text_off < sizeof(*build_info)) {
tr_err(&lib_manager_tr, "Invalid TEXT file_offset %u, lib_size %zu",
text_off, lib_size);
return MOD_TYPE_INVALID;
}

tr_info(&lib_manager_tr, "Module API version: %u.%u.%u, format: 0x%x",
build_info->api_version_number.fields.major,
build_info->api_version_number.fields.middle,
Expand Down
6 changes: 5 additions & 1 deletion src/library_manager/llext_manager_dram.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,14 @@ int llext_manager_restore_from_dram(void)
continue;
}

/* Panics on failure - use the same zone as during the first boot */
struct lib_manager_mod_ctx *ctx = rmalloc(SOF_MEM_FLAG_KERNEL | SOF_MEM_FLAG_COHERENT,
sizeof(*ctx));

if (!ctx) {
tr_err(&lib_manager_tr, "library context allocation failure");
goto nomem;
}

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right — the missing NULL check was a regression from that refactor; this restores it (fail the restore gracefully instead of writing through a NULL ctx). No code change needed beyond what's here.


/* Restore the library context */
*ctx = lib_manager_dram.ctx[j++];

Expand Down
Loading