-
Notifications
You must be signed in to change notification settings - Fork 707
ct/l1: fix UAF in file_io::read_object()
#29172
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
Conversation
This is dangerous because capturing `r = reservation_fut.get()` and then passing a pointer to it to `save_to_cache()` will result in a use-after-free should the future be resolved after the `consumer` lambda is destructed. Change the lambda signature to only capture values that will be moved or copied into `save_to_cache()` to ensure lifetime safety.
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.
Pull request overview
This PR fixes a use-after-free (UAF) bug in file_io::read_object() where a pointer to a stack-allocated reservation object was being captured and passed to an asynchronous callback, potentially causing the pointer to dangle after the lambda's destruction.
Key Changes:
- Changed
save_to_cache()to acceptspace_reservation_guardby value instead of by pointer - Updated lambda capture to move ownership of the reservation and cache_key instead of capturing references
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/v/cloud_topics/level_one/common/file_io.h |
Changed save_to_cache() signature to accept reservation guard by value |
src/v/cloud_topics/level_one/common/file_io.cc |
Updated implementation to move reservation ownership and eliminate pointer usage |
|
EDIT1: EDIT2: Unsure again. |
|
Closing for now, I don't believe this is a fix for the crash observed. |
dotnwat
left a comment
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.
- it's not clear how the UAF would occur--the code looks like it doesn't have the UAF as described.
- passing the reservation by value seems to ignore the original purpose of the reference which was to use the same reservation across multiple invocations of the lambda.
This is dangerous because capturing
r = reservation_fut.get()and then passing a pointer to it tosave_to_cache()will result in a use-after-free should the future be resolved after theconsumerlambda is destructed.Change the lambda signature to only capture values that will be moved or copied into
save_to_cache()to ensure lifetime safety.Relevant Backtrace:
Backports Required
Release Notes