]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commit
librbd: don't complete ImageUpdateWatchers::shut_down() prematurely
authorIlya Dryomov <idryomov@gmail.com>
Wed, 25 Feb 2026 10:37:16 +0000 (11:37 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 25 Feb 2026 10:37:16 +0000 (11:37 +0100)
commit3ea6ee62aa339d1ad9976fdcc6e207a505f9bf44
tree4b021c2e9f33c07762e8347c6e013f713478eb5a
parent53500158f2f258f9d3109c842170abb26ec92f8b
librbd: don't complete ImageUpdateWatchers::shut_down() prematurely

ImageUpdateWatchers::flush() requests aren't tracked with
m_in_flight-like mechanism the way ImageUpdateWatchers::send_notify()
requests are, but in both cases callbacks that represent delayed work
that is very likely to (indirectly) reference ImageCtx are involved.
When the image is getting closed, ImageUpdateWatchers::shut_down() is
called before anything that belongs to ImageCtx is destroyed.  However,
the shutdown can complete prematurely in the face of a pending flush if
one gets sent shortly before CloseRequest is invoked.  The callback for
that flush will then race with CloseRequest and may execute after parts
of or even the entire ImageCtx is destroyed, leading to use-after-free
and various segfaults.

Fixes: https://tracker.ceph.com/issues/75161
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/librbd/ImageState.cc