Skip to contentSkip to conversation

ocfs2-reject-fitrim-ranges-shorter-than-a-cluster.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Jun 4

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: ocfs2: reject FITRIM ranges shorter than a cluster
has been removed from the -mm tree. Its filename was
ocfs2-reject-fitrim-ranges-shorter-than-a-cluster.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Zhang Cen <[email protected]>
Subject: ocfs2: reject FITRIM ranges shorter than a cluster
Date: Thu, 28 May 2026 23:12:47 +0800

ocfs2_trim_mainbm() trims the global bitmap in cluster units, but its too-short range validation only checks sb->s_blocksize.

On filesystems with a cluster size larger than the block size, a FITRIM range that is at least one block but shorter than one cluster is accepted and shifted down to len == 0. The later start + len - 1 and len -= ... arithmetic then underflows and can drive trimming past the requested range.

Reject ranges shorter than s_clustersize instead. That preserves the existing -EINVAL behavior for requests that cannot discard even one allocation unit and keeps zero-cluster trims out of the group walk.

Fixes aa89762c5480 ("ocfs2: return EINVAL if the given range to discard is less than block size")
Assisted-by Codex:gpt-5.5
Cc Mark Fasheh <[email protected]>
Cc Joel Becker <[email protected]>
Cc Junxiao Bi <[email protected]>
Cc Changwei Ge <[email protected]>
Cc Jun Piao <[email protected]>
Cc Heming Zhao <[email protected]>

---

 fs/ocfs2/alloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/alloc.c renamed from fs/ocfs2/alloc.c~ocfs2-reject-fitrim-ranges-shorter-than-a-cluster +1 -1
@@ -7576,7 +7576,7 @@ int ocfs2_trim_mainbm(struct super_block
 	len = range->len >> osb->s_clustersize_bits;
 	minlen = range->minlen >> osb->s_clustersize_bits;
 
-	if (minlen >= osb->bitmap_cpg || range->len < sb->s_blocksize)
+	if (minlen >= osb->bitmap_cpg || range->len < osb->s_clustersize)
 		return -EINVAL;
 
 	trace_ocfs2_trim_mainbm(start, len, minlen);

_

Patches currently in -mm which might be from [email protected] are