FAILED: patch "[PATCH] ceph: clamp the inline data length in ceph_fill_inline_data()" failed to apply to 7.3-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 7.3-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.3.y
git checkout FETCH_HEAD
git cherry-pick -x 9c1d14d3b66b3e1dd96ee664c0dd2548f2b77a52
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 7.3.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 9c1d14d3b66b3e1dd96ee664c0dd2548f2b77a52 Mon Sep 17 00:00:00 2001
From: Guanglei Zhu <[email protected]>
Date: Thu, 10 Sep 2026 11:00:35 +0800
Subject: [PATCH] ceph: clamp the inline data length in ceph_fill_inline_data()
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.
--- fs/ceph/addr.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/ceph/addr.c +6 -0
@@ -2245,6 +2245,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);
Signature · 1 line
2.53.0
PATCH 1/1 ceph: clamp the inline data length in ceph_fill_inline_data()
[ Upstream commit 9c1d14d3b66b3e1dd96ee664c0dd2548f2b77a52 ]
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 page with no length check, so a malicious or buggy MDS returning more inline data than the page can hold writes past its end.
Clamp the length to PAGE_SIZE so both callers, handle_cap_grant() and fill_inode(), are covered.
--- fs/ceph/addr.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/ceph/addr.c +6 -0
@@ -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);
Signature · 1 line
2.43.0
Sasha Levin
maintainerRe: [PATCH 7.3.y] ceph: clamp the inline data length in ceph_fill_inline_data()
Quoted 1 line
ceph: clamp the inline data length in
ceph_fill_inline_data()
A few problems, which apply across all seven trees unless noted:
- On 7.3, 6.18, 6.12 and 6.6 the pr_warn_ratelimited_client() format string is "%zu\\n", which prints a literal backslash-n. Upstream has \n.
- The added if-block is mis-indented on all seven trees (extra tab, closing brace misaligned).
- The backport note says the warning was dropped, but the diff keeps it.
Could you resend all seven with those fixed?
Signature · 2 lines
Thanks, Sasha
PATCH v2 1/1 ceph: clamp the inline data length in ceph_fill_inline_data()
In reply to Guanglei Zhu[ Upstream commit 9c1d14d3b66b3e1dd96ee664c0dd2548f2b77a52 ]
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 page with no length check, so a malicious or buggy MDS returning more inline data than the page can hold writes past its end.
Clamp the length to PAGE_SIZE so both callers, handle_cap_grant() and fill_inode(), are covered.
---
v2: fix the pr_warn_ratelimited_client() format string
(literal backslash-n), drop the extra indentation level on the added if-block, and state per-tree whether the warning is kept (7.3/6.18/6.12/6.6) or dropped (6.1/5.15/5.10), per review.
fs/ceph/addr.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/ceph/addr.c +6 -0
@@ -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);
Signature · 1 line
2.43.0
Re: [PATCH 7.3.y v2] ceph: clamp the inline data length in ceph_fill_inline_data()
Quoted 1 line
ceph: clamp the inline data length in
ceph_fill_inline_data()
Queued for 7.3, 6.18, 6.12, 6.6, 6.1, 5.15 and 5.10, thanks.
Signature · 2 lines
Thanks, Sasha