[PATCH 0/9] ceph: fix mdsmap and osdmap use-after-free in unlocked readers
From: Max Kellermann
Date: Wed Nov 11 2026 - 11:20:30 EST
The MDS and OSD clients replace their maps and free the old ones
under a lock: mdsc->mutex for the mdsmap and osdc->lock for the
osdmap. Several readers dereference these maps without that lock and
can therefore access freed memory if a new map arrives concurrently.
The worst is ceph_statfs(), which any user can reach and which loads
and dereferences a pointer from the old mdsmap.
Each patch takes the lock that protects the replacement around the
reads. __ceph_setxattr() cannot take mdsc->mutex under i_ceph_lock,
so it uses a copy of m_max_xattr_size kept in the mds client.
The same problem in ceph_compare_options() was already fixed by
commit 19db525816db ("libceph: use RCU to protect monmap in
ceph_compare_options()").
These bugs were found by code review and have not been reproduced.
Max Kellermann (9):
ceph: fix mdsmap use-after-free in ceph_statfs()
ceph: fix mdsmap use-after-free in debugfs mdsmap_show()
ceph: fix mdsmap use-after-free in __ceph_setxattr()
ceph: fix mdsmap use-after-free in send_renew_caps() and
renewed_caps()
ceph: fix mdsmap use-after-free in mds_peer_reset()
ceph: fix mdsmap use-after-free in ceph_get_tree() error path
ceph: fix osdmap use-after-free in ceph_sync_setxattr()
libceph: fix osdmap use-after-free in ceph_wait_for_latest_osdmap()
rbd: fix osdmap use-after-free in pool lookups
drivers/block/rbd.c | 13 +++++++++++--
fs/ceph/debugfs.c | 12 ++++++++++--
fs/ceph/mds_client.c | 18 ++++++++++++++++--
fs/ceph/mds_client.h | 7 +++++++
fs/ceph/super.c | 19 ++++++++++++++-----
fs/ceph/xattr.c | 13 +++++++++----
net/ceph/ceph_common.c | 8 +++++++-
7 files changed, 74 insertions(+), 16 deletions(-)
--
2.53.0