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

Use after free in OCL wait_for_interrupt API #1535

Open
mmichal10 opened this issue Sep 26, 2024 · 0 comments
Open

Use after free in OCL wait_for_interrupt API #1535

mmichal10 opened this issue Sep 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mmichal10
Copy link
Contributor

When calling async operation OCL uses _cache_mngt_async_callee_set_result() and _cache_mngt_async_caller_set_result() to communicate whether the caller or the callee is responsible for cleanup.

The API has an invalid assumption - it's not prepared for the callee() part being called before the caller(). This may lead to use-after-free in the caller() code - in case if an async operation is interrupted and the completion function gets called first it marks the completion in struct _cache_mngt_async_context and it frees the context structure instantly. Then, when the caller thread is waked up, it calls _cache_mngt_async_caller_set_result() with the pointer to context, which just has been freed in the completion.

The possible solution is adding reference counter to struct _cache_mngt_async_context

@mmichal10 mmichal10 added the bug Something isn't working label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant