FAILED: patch "[PATCH] xfs: fix integer overflow in bmap intent sort comparator" failed to apply to 6.1-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.1-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-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 362c490980867930a098b99f421268fbd7ca05fd
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026031714-whiff-catalyst-aa41@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 362c490980867930a098b99f421268fbd7ca05fd Mon Sep 17 00:00:00 2001
From: Long Li <[email protected]>
Date: Tue, 10 Mar 2026 20:32:33 +0800
Subject: [PATCH] xfs: fix integer overflow in bmap intent sort comparator
xfs_bmap_update_diff_items() sorts bmap intents by inode number using a subtraction of two xfs_ino_t (uint64_t) values, with the result truncated to int. This is incorrect when two inode numbers differ by more than INT_MAX (2^31 - 1), which is entirely possible on large XFS filesystems.
Fix this by replacing the subtraction with cmp_int().
fs/xfs/xfs_bmap_item.c +1 -1
@@ -245,7 +245,7 @@ xfs_bmap_update_diff_items(struct xfs_bmap_intent *ba =bi_entry (a);struct xfs_bmap_intent *bb =bi_entry (b); -return ba->bi_owner->i_ino - bb->bi_owner->i_ino; +return cmp_int (ba->bi_owner->i_ino, bb->bi_owner->i_ino); }/* Log bmap updates in the intent item. */
Sasha Levin
maintainerPATCH 1/1 xfs: fix integer overflow in bmap intent sort comparator
From: Long Li <[email protected]>
[ Upstream commit 362c490980867930a098b99f421268fbd7ca05fd ]
xfs_bmap_update_diff_items() sorts bmap intents by inode number using a subtraction of two xfs_ino_t (uint64_t) values, with the result truncated to int. This is incorrect when two inode numbers differ by more than INT_MAX (2^31 - 1), which is entirely possible on large XFS filesystems.
Fix this by replacing the subtraction with cmp_int().
--- fs/xfs/xfs_bmap_item.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/xfs/xfs_bmap_item.c +2 -1
@@ -277,7 +277,8 @@ xfs_bmap_update_diff_items( ba = container_of(a, struct xfs_bmap_intent, bi_list); bb = container_of(b, struct xfs_bmap_intent, bi_list); -return ba->bi_owner->i_ino - bb->bi_owner->i_ino; +return (ba->bi_owner->i_ino > bb->bi_owner->i_ino) - + (ba->bi_owner->i_ino < bb->bi_owner->i_ino); }/* Set the map extent flags for this mapping. */
Signature · 1 line
2.51.0