Skip to content
Open
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
15 changes: 15 additions & 0 deletions src/library_manager/lib_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,21 @@ static enum buildinfo_mod_type lib_manager_get_module_type(const struct sof_man_
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.
*/
{
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 +583 to +589
Comment on lines +586 to +589
}

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;
}

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

Expand Down
Loading