The ceph_fuse will unmount the client and then finalize the cfuse
and at the same will free the mountpoint memory. And at last will
try to stop the remount_finisher thread. But the remount_finisher
thread will use the freed mountpoint to do the remount, which will
case unexpected remount failures.
Just stop the remount_finisher thread in the Client::unmount().
Fixes: https://tracker.ceph.com/issues/56249
Signed-off-by: Xiubo Li <xiubli@redhat.com>
mref_writer.update_state(CLIENT_UNMOUNTED);
+ /*
+ * Stop the remount_queue before clearing the mountpoint memory
+ * to avoid possible use-after-free bug.
+ */
+ if (remount_cb) {
+ ldout(cct, 10) << "unmount stopping remount finisher" << dendl;
+ remount_finisher.wait_for_empty();
+ remount_finisher.stop();
+ remount_cb = nullptr;
+ }
+
ldout(cct, 2) << "unmounted." << dendl;
}