FAILED: patch "[PATCH] ceph: validate MDS reply fragtree split array length" failed to apply to 5.15-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 5.15-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-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 8cab7e7461f81ea1e0fd45082b50bb3c04c0bb10
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 8cab7e7461f81ea1e0fd45082b50bb3c04c0bb10 Mon Sep 17 00:00:00 2001
From: sung byeongchan <[email protected]>
Date: Thu, 8 Oct 2026 15:07:25 +0900
Subject: [PATCH] ceph: validate MDS reply fragtree split array length
parse_reply_info_in() advances over the fragtree split array using an unchecked count multiplication. On a 32-bit client, nsplits=0x20000000 wraps the byte length to zero, so the reply is accepted and ceph_fill_fragtree() sorts far beyond the message front.
Compute the split length with size_mul() and require the complete array to remain in the inode record before advancing the cursor.
The malformed reply faulted in frag_tree_split_cmp() twice on the tested i386 baseline. It was rejected without a fault twice after this change, while a normal reply and a one-split control remained functional.
--- fs/ceph/mds_client.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/ceph/mds_client.c +7 -3
@@ -15,6 +15,7 @@#include <linux/ktime.h> #include <linux/bitmap.h> #include <linux/mnt_idmapping.h> +#include <linux/overflow.h> #include "super.h" #include "mds_client.h"
@@ -146,6 +147,7 @@ static int parse_reply_info_in(void **p, void *end, struct ceph_mds_client *mdsc) {int err =0 ; +size_t splits_len;u8 struct_v =0 ;u8 struct_compat =0 ;u32 struct_len =0 ;
@@ -166,9 +168,11 @@ static int parse_reply_info_in(void **p, void *end,ceph_decode_need (p, end,sizeof (struct ceph_mds_reply_inode ), bad); info->in = *p; - *p +=sizeof (struct ceph_mds_reply_inode ) + -sizeof (*info->in->fragtree.splits) * -le32_to_cpu (info->in->fragtree.nsplits); + splits_len =size_mul (sizeof (*info->in->fragtree.splits), +le32_to_cpu (info->in->fragtree.nsplits)); + *p +=sizeof (struct ceph_mds_reply_inode ); +ceph_decode_need (p, end, splits_len, bad); + *p += splits_len;ceph_decode_32_safe (p, end, info->symlink_len, bad);ceph_decode_need (p, end, info->symlink_len, bad);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ceph: validate MDS reply fragtree split array length
From: sung byeongchan <[email protected]>
[ Upstream commit 8cab7e7461f81ea1e0fd45082b50bb3c04c0bb10 ]
parse_reply_info_in() advances over the fragtree split array using an unchecked count multiplication. On a 32-bit client, nsplits=0x20000000 wraps the byte length to zero, so the reply is accepted and ceph_fill_fragtree() sorts far beyond the message front.
Compute the split length with size_mul() and require the complete array to remain in the inode record before advancing the cursor.
The malformed reply faulted in frag_tree_split_cmp() twice on the tested i386 baseline. It was rejected without a fault twice after this change, while a normal reply and a one-split control remained functional.
--- fs/ceph/mds_client.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/ceph/mds_client.c +7 -3
@@ -13,6 +13,7 @@#include <linux/bits.h> #include <linux/ktime.h> #include <linux/bitmap.h> +#include <linux/overflow.h> #include "super.h" #include "mds_client.h"
@@ -102,6 +103,7 @@ static int parse_reply_info_in(void **p, void *end, u64 features) {int err =0 ; +size_t splits_len;u8 struct_v =0 ;if (features == (u64)-1 ) {
@@ -120,9 +122,11 @@ static int parse_reply_info_in(void **p, void *end,ceph_decode_need (p, end,sizeof (struct ceph_mds_reply_inode ), bad); info->in = *p; - *p +=sizeof (struct ceph_mds_reply_inode ) + -sizeof (*info->in->fragtree.splits) * -le32_to_cpu (info->in->fragtree.nsplits); + splits_len =size_mul (sizeof (*info->in->fragtree.splits), +le32_to_cpu (info->in->fragtree.nsplits)); + *p +=sizeof (struct ceph_mds_reply_inode ); +ceph_decode_need (p, end, splits_len, bad); + *p += splits_len;ceph_decode_32_safe (p, end, info->symlink_len, bad);ceph_decode_need (p, end, info->symlink_len, bad);
Signature · 1 line
2.53.0