All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ceph: clamp the inline data length in ceph_fill_inline_data()
@ 2026-09-08  6:21 Guanglei Zhu
  2026-09-08  6:21 ` [PATCH 2/2] ceph: fix out-of-bounds read in ceph_netfs_issue_op_inline() Guanglei Zhu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Guanglei Zhu @ 2026-09-08  6:21 UTC (permalink / raw)
  To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko
  Cc: ceph-devel, linux-kernel, stable

The MDS decides how much inline data to attach to a reply, and the
client parses inline_len without any upper bound: ceph_decode_need()
only verifies that the message actually carries that many bytes.
ceph_fill_inline_data() then memcpy()s the data into a single page
with no length check, so a malicious or buggy MDS returning more than
one page of inline data makes the client write past the end of the
page it allocated.

Clamp the length to PAGE_SIZE so both callers, handle_cap_grant() and
fill_inode(), are covered.

Fixes: 31c542a199d7 ("ceph: add inline data to pagecache")
Cc: stable@vger.kernel.org
Signed-off-by: Guanglei Zhu <zhugl3@xiaopeng.com>
---

Tested in a QEMU guest with a hacked MDS that reports an 8k inline
payload for a 4k file: without the clamp the client overwrites the
page behind the inline page and page poisoning complains on the next
allocation; with it the data is truncated and a warning is logged.
 fs/ceph/addr.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index e598b2d42..795cd1b9e 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -2209,6 +2209,12 @@ void ceph_fill_inline_data(struct inode *inode, struct page *locked_page,
 	doutc(cl, "%p %llx.%llx len %zu locked_page %p\n", inode,
 	      ceph_vinop(inode), len, locked_page);
 
+	if (len > PAGE_SIZE) {
+		pr_warn_ratelimited_client(cl, "oversized inline data %zu\n",
+					   len);
+		len = PAGE_SIZE;
+	}
+
 	if (len > 0) {
 		void *kaddr = kmap_atomic(page);
 		memcpy(kaddr, data, len);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-10  3:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08  6:21 [PATCH 1/2] ceph: clamp the inline data length in ceph_fill_inline_data() Guanglei Zhu
2026-09-08  6:21 ` [PATCH 2/2] ceph: fix out-of-bounds read in ceph_netfs_issue_op_inline() Guanglei Zhu
2026-09-09 12:28 ` [PATCH 1/2] ceph: clamp the inline data length in ceph_fill_inline_data() Alex Markuze
2026-09-10  3:00 ` [PATCH v2 " Guanglei Zhu
2026-09-10  3:00   ` [PATCH v2 2/2] ceph: fix out-of-bounds read in ceph_netfs_issue_op_inline() Guanglei Zhu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.