Skip to content

Commit fc1010e

Browse files
lexiaoxgregkh
authored andcommitted
libceph: remove debugfs files before client teardown
commit e4c8047 upstream. ceph_destroy_client() tears down the monitor client before removing the per-client debugfs files. A concurrent read of the monmap debugfs file can enter monmap_show() after ceph_monc_stop() has freed monc->monmap, triggering a use-after-free. Remove the debugfs files before stopping the OSD and monitor clients. debugfs_remove() drains active handlers and prevents new accesses, so the debugfs callbacks can no longer race the rest of client teardown. Cc: stable@vger.kernel.org Fixes: 76aa844 ("ceph: debugfs") Reported-by: Yuan Tan <yuantan098@gmail.com> Reported-by: Zhengchuan Liang <zcliangcn@gmail.com> Reported-by: Xin Liu <bird@lzu.edu.cn> Assisted-by: Codex:GPT-5.4 Signed-off-by: Douya Le <ldy3087146292@gmail.com> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn> Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b8a9fb6 commit fc1010e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

net/ceph/ceph_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,13 +763,13 @@ void ceph_destroy_client(struct ceph_client *client)
763763

764764
atomic_set(&client->msgr.stopping, 1);
765765

766+
ceph_debugfs_client_cleanup(client);
767+
766768
/* unmount */
767769
ceph_osdc_stop(&client->osdc);
768770
ceph_monc_stop(&client->monc);
769771
ceph_messenger_fini(&client->msgr);
770772

771-
ceph_debugfs_client_cleanup(client);
772-
773773
ceph_destroy_options(client->options);
774774

775775
kfree(client);

0 commit comments

Comments
 (0)