Repository navigation
rgw/posix: fix use-after-free in read_obj_policy - #2
Merged
Conversation
and stale cache in multipart list_parts In read_obj_policy(), the MultipartUpload was scoped inside the if-block, and its shadow bucket was destroyed while mpobj still held a dangling pointer to it. Moving the declaration to the function scope keeps the shadow bucket alive for the duration of the call, fixing a SIGSEGV in POSIXObject::stat() during multipart part uploads. In POSIXMultipartUpload::list_parts(), the bucket cache for the shadow directory could be filled before parts were uploaded (e.g. by a ListParts call during upload), causing CompleteMultipart to see zero parts. Invalidating the shadow bucket cache before listing ensures parts written to disk are always found. Fixes: https://tracker.ceph.com/issues/77597 Signed-off-by: Mark Kogan <[email protected]>
Author
mattbenjamin
pushed a commit
that referenced
this pull request
Jun 24, 2026
…tive list
unittest_posix_bucket_cache failed under LeakSanitizer:
==40342==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 248 byte(s) in 1 object(s) allocated from:
#1 BucketCacheEntry<>::Factory::alloc() src/rgw/driver/posix/bucket_cache.h:114
#2 cohort::lru::LRU<std::mutex>::insert(...) src/common/cohort_lru.h:269
ceph#3 BucketCache<>::get_bucket(...) src/rgw/driver/posix/bucket_cache.h:352
ceph#4 BucketCache<>::list_bucket(...) src/rgw/driver/posix/bucket_cache.h:437
ceph#5 BucketCacheFixtureDefault_ListTDir1_Test::TestBody() src/test/rgw/test_posix_bucket_cache.cc:199
The leaked object is a BucketCacheEntry the suite never frees at exit. The
corruption behind it is a race in the multithreaded ListThreads test, so the
leak is intermittent and does not show on every run.
LRU::unref() moves an object from the non-evictable active list to the evictable
q when its last initial ref is dropped, but it never cleared the object's active
flag. Each Object has a single intrusive lane hook, so the next ref()/unref()
read the stale flag and erased the object from the wrong list, active instead of
q. That corrupts both lanes' constant_time_size counters and leaves the entry
orphaned off the lanes. BucketCache's teardown drains the lanes to free their
entries, so it never frees that one, and LeakSanitizer flags it.
Clear the flag when the object moves to q so it always tracks the list it is on.
The leak no longer reproduces.
Signed-off-by: Kefu Chai <[email protected]>
Signed-off-by: Matt Benjamin <[email protected]>
mattbenjamin
pushed a commit
that referenced
this pull request
Jun 25, 2026
…tive list
unittest_posix_bucket_cache failed under LeakSanitizer:
==40342==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 248 byte(s) in 1 object(s) allocated from:
#1 BucketCacheEntry<>::Factory::alloc() src/rgw/driver/posix/bucket_cache.h:114
#2 cohort::lru::LRU<std::mutex>::insert(...) src/common/cohort_lru.h:269
ceph#3 BucketCache<>::get_bucket(...) src/rgw/driver/posix/bucket_cache.h:352
ceph#4 BucketCache<>::list_bucket(...) src/rgw/driver/posix/bucket_cache.h:437
ceph#5 BucketCacheFixtureDefault_ListTDir1_Test::TestBody() src/test/rgw/test_posix_bucket_cache.cc:199
The leaked object is a BucketCacheEntry the suite never frees at exit. The
corruption behind it is a race in the multithreaded ListThreads test, so the
leak is intermittent and does not show on every run.
LRU::unref() moves an object from the non-evictable active list to the evictable
q when its last initial ref is dropped, but it never cleared the object's active
flag. Each Object has a single intrusive lane hook, so the next ref()/unref()
read the stale flag and erased the object from the wrong list, active instead of
q. That corrupts both lanes' constant_time_size counters and leaves the entry
orphaned off the lanes. BucketCache's teardown drains the lanes to free their
entries, so it never frees that one, and LeakSanitizer flags it.
Clear the flag when the object moves to q so it always tracks the list it is on.
The leak no longer reproduces.
Signed-off-by: Kefu Chai <[email protected]>
Signed-off-by: Matt Benjamin <[email protected]>
mattbenjamin
pushed a commit
that referenced
this pull request
Jul 14, 2026
…tive list
unittest_posix_bucket_cache failed under LeakSanitizer:
==40342==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 248 byte(s) in 1 object(s) allocated from:
#1 BucketCacheEntry<>::Factory::alloc() src/rgw/driver/posix/bucket_cache.h:114
#2 cohort::lru::LRU<std::mutex>::insert(...) src/common/cohort_lru.h:269
ceph#3 BucketCache<>::get_bucket(...) src/rgw/driver/posix/bucket_cache.h:352
ceph#4 BucketCache<>::list_bucket(...) src/rgw/driver/posix/bucket_cache.h:437
ceph#5 BucketCacheFixtureDefault_ListTDir1_Test::TestBody() src/test/rgw/test_posix_bucket_cache.cc:199
The leaked object is a BucketCacheEntry the suite never frees at exit. The
corruption behind it is a race in the multithreaded ListThreads test, so the
leak is intermittent and does not show on every run.
LRU::unref() moves an object from the non-evictable active list to the evictable
q when its last initial ref is dropped, but it never cleared the object's active
flag. Each Object has a single intrusive lane hook, so the next ref()/unref()
read the stale flag and erased the object from the wrong list, active instead of
q. That corrupts both lanes' constant_time_size counters and leaves the entry
orphaned off the lanes. BucketCache's teardown drains the lanes to free their
entries, so it never frees that one, and LeakSanitizer flags it.
Clear the flag when the object moves to q so it always tracks the list it is on.
The leak no longer reproduces.
Signed-off-by: Kefu Chai <[email protected]>
Signed-off-by: Matt Benjamin <[email protected]>
mattbenjamin
pushed a commit
that referenced
this pull request
Nov 13, 2026
…tive list
unittest_posix_bucket_cache failed under LeakSanitizer:
==40342==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 248 byte(s) in 1 object(s) allocated from:
#1 BucketCacheEntry<>::Factory::alloc() src/rgw/driver/posix/bucket_cache.h:114
#2 cohort::lru::LRU<std::mutex>::insert(...) src/common/cohort_lru.h:269
ceph#3 BucketCache<>::get_bucket(...) src/rgw/driver/posix/bucket_cache.h:352
ceph#4 BucketCache<>::list_bucket(...) src/rgw/driver/posix/bucket_cache.h:437
ceph#5 BucketCacheFixtureDefault_ListTDir1_Test::TestBody() src/test/rgw/test_posix_bucket_cache.cc:199
The leaked object is a BucketCacheEntry the suite never frees at exit. The
corruption behind it is a race in the multithreaded ListThreads test, so the
leak is intermittent and does not show on every run.
LRU::unref() moves an object from the non-evictable active list to the evictable
q when its last initial ref is dropped, but it never cleared the object's active
flag. Each Object has a single intrusive lane hook, so the next ref()/unref()
read the stale flag and erased the object from the wrong list, active instead of
q. That corrupts both lanes' constant_time_size counters and leaves the entry
orphaned off the lanes. BucketCache's teardown drains the lanes to free their
entries, so it never frees that one, and LeakSanitizer flags it.
Clear the flag when the object moves to q so it always tracks the list it is on.
The leak no longer reproduces.
Signed-off-by: Kefu Chai <[email protected]>
Signed-off-by: Matt Benjamin <[email protected]>
Signed-off-by: Daniel Gryniewicz <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



and stale cache in multipart list_parts
In read_obj_policy(), the MultipartUpload was scoped inside the if-block, and its shadow bucket was destroyed while mpobj still held a dangling pointer to it. Moving the declaration to the function scope keeps the shadow bucket alive for the duration of the call, fixing a SIGSEGV in
POSIXObject::stat() during multipart part uploads.
In POSIXMultipartUpload::list_parts(), the bucket cache for the shadow directory could be filled before parts were uploaded (e.g. by a ListParts call during upload), causing CompleteMultipart to see zero parts. Invalidating the shadow bucket cache before listing ensures parts written to disk are always found.
Fixes: https://tracker.ceph.com/issues/77597