Skip to content

tentacle: librbd: fix use-after-free releasing object map locks in deep copy - #70010

Merged
batrick merged 1 commit into
ceph:tentaclefrom
tchaikov:wip-77716-tentacle
Jul 21, 2026
Merged

batrick merged 1 commit into
ceph:tentaclefrom
tchaikov:wip-77716-tentacle

Conversation

@tchaikov

@tchaikov tchaikov commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

DeepCopyRequest::send_copy_object_map() holds the destination image's
owner_lock and image_lock (shared), issues an asynchronous
object_map->rollback(), and then releases the two locks through
m_dst_image_ctx.  The rollback callback drives the rest of the request to
completion (handle_copy_object_map() ... finish() -> put()) on other
threads.  That path needs image_lock, so it only proceeds once this method
releases it, and can then run to completion and free 'this' before the
following owner_lock.unlock_shared() executes, dereferencing the freed
DeepCopyRequest.

ASan reported this as a heap-use-after-free in
TestImageReplayer.StartReplayAndWrite: the object was freed on the finisher
thread (handle_copy_metadata() -> finish()) while the io_context thread was
still in send_copy_object_map().

The destination image ctx outlives the request, so operate through a local
reference to it and release the locks through that reference rather than
through 'this', as
operation/SnapshotRollbackRequest::send_rollback_object_map() already does.

Keep the explicit lock_shared()/unlock_shared() calls rather than scoped
std::shared_lock guards: unlike
operation/SnapshotRollbackRequest::send_rollback_object_map(),
send_copy_object_map() has four exit paths (send_copy_metadata(),
send_refresh_object_map(), finish(), and the object map rollback), each of
which must release the locks before running a different continuation, so
RAII guards would push that continuation out of the locked scope and read
less clearly than unlocking at each exit.

Fixes: https://tracker.ceph.com/issues/77551
Signed-off-by: Kefu Chai <[email protected]>
(cherry picked from commit ecd883a)
@tchaikov
tchaikov requested a review from a team as a code owner July 8, 2026 00:35
@tchaikov tchaikov added this to the tentacle milestone Jul 8, 2026
@tchaikov tchaikov added the rbd label Jul 8, 2026
@github-actions github-actions Bot added the releng-audit-pass Release engineering: passed backport verification audit. label Jul 8, 2026
@yuriw

yuriw commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-yuri-testing-20260715.192214-tentacle.

@idryomov idryomov modified the milestones: tentacle, v20.2.3 Jul 20, 2026
@idryomov

Copy link
Copy Markdown
Contributor

jenkins test docs

@batrick batrick added the releng-audit-queue Release engineering: queued for backport verification audit. label Jul 21, 2026
@github-actions github-actions Bot added releng-audit-pass Release engineering: passed backport verification audit. and removed releng-audit-queue Release engineering: queued for backport verification audit. releng-audit-pass Release engineering: passed backport verification audit. labels Jul 21, 2026
@batrick
batrick merged commit 6c4d021 into ceph:tentacle Jul 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-qa rbd releng-audit-pass Release engineering: passed backport verification audit. wip-yuri-testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants