Skip to content

Commit

Permalink
lib_manager: Verify preload_page_count from module manifest
Browse files Browse the repository at this point in the history
The preload_page_count value from the loadable library manifest is used to
determine size of allocated memory buffer. If this value is smaller than
the manifest size, it will lead to memory corruption.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
  • Loading branch information
softwarecki committed Mar 11, 2024
1 parent da99651 commit 0e05cef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/library_manager/lib_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,16 @@ static int lib_manager_store_library(struct lib_manager_dma_ext *dma_ext,
uint32_t preload_size = man_desc->header.preload_page_count * PAGE_SZ;
int ret;

/*
* The module manifest structure always has its maximum size regardless of
* the actual size of the manifest.
*/
if (preload_size < MAN_MAX_SIZE_V1_8) {
tr_err(&lib_manager_tr, "Invalid preload_size value %x.", preload_size);
return -EINVAL;
}

/* Prepare storage memory, note: it is never freed, library unloading is unsupported */
/*
* Prepare storage memory, note: it is never freed, it is assumed, that this
* memory is abundant, so we store all loaded modules there permanently
Expand Down

0 comments on commit 0e05cef

Please sign in to comment.