Skip to content

ceph: fix mdsmap and osdmap use-after-free in unlocked readers

Max Kellermann ceph-devel lkml stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9ceph: fix mdsmap use-after-free in ceph_statfs()fs/ceph/super.c+8 -40 replies
2/9ceph: fix mdsmap use-after-free in debugfs mdsmap_show()fs/ceph/debugfs.c+10 -20 replies
3/9ceph: fix mdsmap use-after-free in __ceph_setxattr()fs/ceph/mds_client.c fs/ceph/mds_client.h fs/ceph/xattr.c+14 -40 replies
4/9ceph: fix mdsmap use-after-free in send_renew_caps() and renewed_caps()fs/ceph/mds_client.c+8 -10 replies
5/9ceph: fix mdsmap use-after-free in mds_peer_reset()fs/ceph/mds_client.c+7 -10 replies
6/9ceph: fix mdsmap use-after-free in ceph_get_tree() error pathfs/ceph/super.c+6 -10 replies
7/9ceph: fix osdmap use-after-free in ceph_sync_setxattr()fs/ceph/xattr.c+3 -00 replies
8/9libceph: fix osdmap use-after-free in ceph_wait_for_latest_osdmap()net/ceph/ceph_common.c+7 -10 replies
9/9rbd: fix osdmap use-after-free in pool lookupsdrivers/block/rbd.c+11 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/9] ceph: fix mdsmap and osdmap use-after-free in unlocked readers

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(-)
Signature · 1 line
2.53.0