Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib_manager: llext_manager: Add const to variables and function parameters cleanup #8898

Merged
merged 7 commits into from
Mar 13, 2024

Conversation

softwarecki
Copy link
Collaborator

Added a const modifier to the module manifest variable in the lib_manager_store_library function to prevent it from being accidentally modified.

Added verification of preload_page_count from module manifest. 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.

Removed pointer to a library manifest from the parameters list of the lib_manager_register_module function.

Instead of a pointer to a component driver and ipc config, the lib_manager_free_module and llext_manager_free_module functions now gets component id.

To prevent unintentional modification of a loadable library manifest, a const modifier has been added to all variables pointing to it.

Added a const modifier to the ipc_config parameter passed to functions lib_manager_allocate_module and llext_manager_allocate_module.

Removed unused desc parameter from llext_manager_load_module and llext_manager_unload_module functions.

@softwarecki softwarecki force-pushed the manager-cleanup branch 2 times, most recently from 589c508 to 122e9c4 Compare March 5, 2024 09:03
@softwarecki softwarecki marked this pull request as ready for review March 5, 2024 09:04
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me. One question inline on some of the interface changes, but nothing really major.

src/library_manager/lib_manager.c Show resolved Hide resolved
src/library_manager/lib_manager.c Show resolved Hide resolved
lyakh
lyakh previously requested changes Mar 7, 2024
src/library_manager/lib_manager.c Show resolved Hide resolved
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

LGTM, only minor updates needed and we are good to go.

src/library_manager/lib_manager.c Show resolved Hide resolved
@softwarecki softwarecki requested a review from lyakh March 8, 2024 14:36
@lyakh lyakh dismissed their stale review March 11, 2024 07:22

the missing lib_manager_free_module() instance got fixed, but component_id still conflicts with the component API IMHO

Added a const modifier to the module manifest variable in the
lib_manager_store_library function to prevent it from being accidentally
modified.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
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>
Removed pointer to a library manifest from the parameters list of the
lib_manager_register_module function.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Instead of a pointer to a component driver and ipc config, the
lib_manager_free_module and llext_manager_free_module functions now gets
component id.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
…nters

To prevent unintentional modification of a loadable library manifest,
a const modifier has been added to all variables pointing to it.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Added a const modifier to the ipc_config parameter passed to functions
lib_manager_allocate_module and llext_manager_allocate_module.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Removed unused desc parameter from llext_manager_load_module and
llext_manager_unload_module functions.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
lyakh
lyakh previously requested changes Mar 12, 2024
Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

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

In principle I like adding const to pointers in general and to pointer function arguments in particular. But I think this has to be improved:

  1. I disagree with the "component ID" part
  2. in one location an existing function should be used instead of open-coding
  3. let's do that after we revert the lib_manager_free_module() as per bc79c69

src/ipc/ipc4/helper.c Show resolved Hide resolved
src/library_manager/lib_manager.c Show resolved Hide resolved
src/library_manager/llext_manager.c Show resolved Hide resolved
src/library_manager/llext_manager.c Show resolved Hide resolved
@softwarecki
Copy link
Collaborator Author

3. let's do that after we revert the lib_manager_free_module() as per bc79c69

@lyakh I don't see any connection between this PR and the linked one and I don't think stopping it is justified.

@lyakh
Copy link
Collaborator

lyakh commented Mar 13, 2024

  1. let's do that after we revert the lib_manager_free_module() as per bc79c69

@lyakh I don't see any connection between this PR and the linked one and I don't think stopping it is justified.

@softwarecki ok, you're right: the revert only touches modules.c and this PR hardly touches it. Let me remove my "request for change" then, but I still stand by my other two comments. Besides, as of yesterday the QB seems to be broken, which would also fail this PR if you update it #8933 (comment)

@lyakh lyakh dismissed their stale review March 13, 2024 07:13

my main objection turned out to be invalid, the revert should still be possible on top of this PR

@kv2019i
Copy link
Collaborator

kv2019i commented Mar 13, 2024

@kv2019i kv2019i merged commit 9ffff14 into thesofproject:main Mar 13, 2024
77 of 83 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.

5 participants