From: Max Kellermann <max.kellermann@ionos.com>
To: xiubli@redhat.com, idryomov@gmail.com, amarkuze@redhat.com,
ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Max Kellermann <max.kellermann@ionos.com>, stable@vger.kernel.org
Subject: [PATCH 7/9] ceph: fix osdmap use-after-free in ceph_sync_setxattr()
Date: Wed, 11 Nov 2026 17:18:28 +0100 [thread overview]
Message-ID: <20261111161830.1336485-8-max.kellermann@ionos.com> (raw)
In-Reply-To: <20261111161830.1336485-1-max.kellermann@ionos.com>
ceph_sync_setxattr() reads osdc->osdmap->epoch without holding
osdc->lock, but ceph_osdc_handle_map() replaces the osdmap and frees
the old one under that lock (held for writing). A setxattr() racing
with an osdmap update can therefore read the epoch from freed memory
and send a garbage epoch to the MDS, which uses it to decide whether
it needs a newer osdmap to validate the layout.
Read the epoch while holding osdc->lock for reading.
Fixes: 968cd14edc3a ("ceph: set osdmap epoch for setxattr")
Cc: stable@vger.kernel.org
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/ceph/xattr.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 8f97b6448d7a..64ccf70aa3dd 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -1179,8 +1179,11 @@ static int ceph_sync_setxattr(struct inode *inode, const char *name,
if (op == CEPH_MDS_OP_SETXATTR) {
req->r_args.setxattr.flags = cpu_to_le32(flags);
+ /* ceph_osdc_handle_map() replaces and frees the osdmap */
+ down_read(&osdc->lock);
req->r_args.setxattr.osdmap_epoch =
cpu_to_le32(osdc->osdmap->epoch);
+ up_read(&osdc->lock);
req->r_pagelist = pagelist;
pagelist = NULL;
}
--
2.53.0
next prev parent reply other threads:[~2026-11-11 16:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 16:18 [PATCH 0/9] ceph: fix mdsmap and osdmap use-after-free in unlocked readers Max Kellermann
2026-11-11 16:18 ` [PATCH 1/9] ceph: fix mdsmap use-after-free in ceph_statfs() Max Kellermann
2026-11-11 16:18 ` [PATCH 2/9] ceph: fix mdsmap use-after-free in debugfs mdsmap_show() Max Kellermann
2026-11-11 16:18 ` [PATCH 3/9] ceph: fix mdsmap use-after-free in __ceph_setxattr() Max Kellermann
2026-11-11 16:18 ` [PATCH 4/9] ceph: fix mdsmap use-after-free in send_renew_caps() and renewed_caps() Max Kellermann
2026-11-11 16:18 ` [PATCH 5/9] ceph: fix mdsmap use-after-free in mds_peer_reset() Max Kellermann
2026-11-11 16:18 ` [PATCH 6/9] ceph: fix mdsmap use-after-free in ceph_get_tree() error path Max Kellermann
2026-11-11 16:18 ` Max Kellermann [this message]
2026-11-11 16:18 ` [PATCH 8/9] libceph: fix osdmap use-after-free in ceph_wait_for_latest_osdmap() Max Kellermann
2026-11-11 16:18 ` [PATCH 9/9] rbd: fix osdmap use-after-free in pool lookups Max Kellermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261111161830.1336485-8-max.kellermann@ionos.com \
--to=max.kellermann@ionos.com \
--cc=amarkuze@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=xiubli@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®