-
Notifications
You must be signed in to change notification settings - Fork 322
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
regions_mm: vmh_free: Prevent null pointer dereference #9776
Conversation
@kv2019i needed for v2.12 or is VMH not enabled ? |
zephyr/lib/alloc.c
Outdated
tr_err(&zephyr_tr, "Unable to free %p! %d", ptr, ret); | ||
k_panic(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again not sure I understand why this is needed. Should we panic in all error cases? Or at least in all cases where we cannot directly propagate the error up the stack? Maybe we should use or add an IPC notification for some such cases.
@lgirdwood wrote:
VMH is now enabled for all Intel ACE platforms (CONFIG_VIRTUAL_HEAP=y), so this does affect the release. I'll postpone the release tag until we have clarify. It's not clear under which circumstances this failure can happen (and i.e. how serious this is)? But to err on safe side, not tagging release until we have clarity. |
@softwarecki can you provide details on the reproduction i.e. can in impact v2.12 ? Thanks ! |
594bf98
to
fcbca60
Compare
@lgirdwood @kv2019i @lyakh The |
@softwarecki That's a very good explanation, thank you! Now the issues are becoming clearer, so we can think how to fix them.
|
The vmh_free function may have referenced a null pointer if an invalid pointer to be freed was passed to it. Before referencing the allocator array item, check if it has been initialized. Signed-off-by: Adrian Warecki <[email protected]>
1ac29cd
to
25216e5
Compare
issue clarified, unneeded k_panic()
addition removed
|
@softwarecki wrote:
Sorry, I need your help with this one. This is getting more than usual attention as we were supposed to tag final 2.12 today and this is the only issue left. As far as I can tell, this invalid free can only happen with ipc4_get_large_config_module_instance() if sent to a module running on non-zero core? I'm puzzled why we haven't hit this in CI before. The NULL dereference is on read, so should create a normal Zephyr panic when hit. Not a mainstream case, but I guess we need to have this in the release. |
@kv2019i It has to be an IPC response with payload sent by a secondary core. I guess we don't have those in our tests. Maybe we should add some. Which IPCs return payload? Something like get-config? Can we test some of those on secondary cores? |
@softwarecki with |
@kv2019i with my incomplete knowledge of all IPC4 response cases, I'd tend to agree. |
Update on this: I've been reviewing impacts of the bug this is addressing and seems this case cannot be hit in configurations we are shipping in public releases. Given this and issues with CI getting this merged, I'm leaning to exclude this from 2.12 final tag today. @lgirdwood @softwarecki @lyakh please add if you have further data points to consider |
@kv2019i It looks like this bug cannot trigger with any of the topologies, included in SOF official releases, so to trigger it you'd need a custom topology. It still doesn't feel particularly happy, but well, if a bug cannot be triggered, it doesn't exist... |
The vmh_free function may have referenced a null pointer if an invalid pointer was passed to it. Before referencing the allocator array item, check if it has been initialized.
Add k_panic() function call in error handling code to help detect potential memory release errors.