From: Guanglei Zhu <zhugl3@xiaopeng.com>
To: Ilya Dryomov <idryomov@gmail.com>,
Alex Markuze <amarkuze@redhat.com>,
Viacheslav Dubeyko <slava@dubeyko.com>
Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH v2 1/2] ceph: clamp the inline data length in ceph_fill_inline_data()
Date: Thu, 10 Sep 2026 11:00:35 +0800 [thread overview]
Message-ID: <20260910030036.1045515-1-zhugl3@xiaopeng.com> (raw)
In-Reply-To: <20260908062119.402027-1-zhugl3@xiaopeng.com>
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 copies the data into a single folio
with no length check, so a malicious or buggy MDS returning more
inline data than the folio can hold writes past its end.
Clamp the length to folio_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>
---
- rebase onto ceph-client.git testing, where ceph_fill_inline_data()
was converted to folios; clamp to folio_size() instead of PAGE_SIZE
(reported by Alex Markuze)
fs/ceph/addr.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 4a2d3352a..3c7cf8a5e 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -2266,6 +2266,12 @@ void ceph_fill_inline_data(struct inode *inode, struct folio *locked_folio,
doutc(cl, "%p %llx.%llx len %zu locked_folio %p\n", inode,
ceph_vinop(inode), len, locked_folio);
+ if (len > folio_size(folio)) {
+ pr_warn_ratelimited_client(cl, "oversized inline data %zu\n",
+ len);
+ len = folio_size(folio);
+ }
+
if (len > 0)
memcpy_to_folio(folio, 0, data, len);
--
2.43.0
next prev parent reply other threads:[~2026-09-10 3:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Guanglei Zhu [this message]
2026-09-10 3:00 ` [PATCH v2 2/2] ceph: fix out-of-bounds read in ceph_netfs_issue_op_inline() Guanglei Zhu
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=20260910030036.1045515-1-zhugl3@xiaopeng.com \
--to=zhugl3@xiaopeng.com \
--cc=amarkuze@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=slava@dubeyko.com \
--cc=stable@vger.kernel.org \
/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 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.