Skip to contentSkip to conversation

ocfs2-reject-inconsistent-xattr-bucket-during-defrag.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Oct 7

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: ocfs2: reject inconsistent xattr bucket during defrag
has been removed from the -mm tree. Its filename was
ocfs2-reject-inconsistent-xattr-bucket-during-defrag.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: Joseph Qi <[email protected]>
Subject: ocfs2: reject inconsistent xattr bucket during defrag
Date: Thu, 3 Sep 2026 21:13:13 +0800

ocfs2_defrag_xattr_bucket() has two mlog_bug_on_msg() checks that assume the name/value pairs in a bucket are disjoint and that xh_free_start is not below the compacted region.

ocfs2_validate_xattr_bucket() only checks each entry in isolation, so a corrupt bucket holding overlapping entries, or one with an inflated xh_free_start, passes validation and then hits BUG() in defrag when a setxattr triggers it.

Defrag works on a linear copy of the bucket and does not touch the real blocks before the copy back, so the checks can return an error instead of calling BUG().

Fixes 012255961c9e ("ocfs2: Enable xattr set in index btree")
Cc Changwei Ge <[email protected]>
Cc Heming Zhao <[email protected]>
Cc Joel Becker <[email protected]>
Cc Jun Piao <[email protected]>
Cc Junxiao Bi <[email protected]>
Cc Mark Fasheh <[email protected]>

---

 fs/ocfs2/xattr.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
fs/ocfs2/xattr.c renamed from fs/ocfs2/xattr.c~ocfs2-reject-inconsistent-xattr-bucket-during-defrag +11 -5
@@ -4801,16 +4801,22 @@ static int ocfs2_defrag_xattr_bucket(str
 			memmove(bucket_buf + end - len,
 				bucket_buf + offset, len);
 			xe->xe_name_offset = cpu_to_le16(end - len);
+		} else if (end < offset + len) {
+			ret = ocfs2_error(inode->i_sb,
+					  "Defrag check failed for bucket %llu\n",
+					  (unsigned long long)blkno);
+			goto out;
 		}
 
-		mlog_bug_on_msg(end < offset + len, "Defrag check failed for "
-				"bucket %llu\n", (unsigned long long)blkno);
-
 		end -= len;
 	}
 
-	mlog_bug_on_msg(xh_free_start > end, "Defrag check failed for "
-			"bucket %llu\n", (unsigned long long)blkno);
+	if (xh_free_start > end) {
+		ret = ocfs2_error(inode->i_sb,
+				  "Defrag check failed for bucket %llu\n",
+				  (unsigned long long)blkno);
+		goto out;
+	}
 
 	if (xh_free_start == end)
 		goto out;

_

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

ocfs2-retain-all-security-xattrs-during-inode-creation.patch ocfs2-restore-erange-check-in-ocfs2_xattr_tree_list_index_block.patch ocfs2-fix-possible-deadlock-between-nfs_sync_rwlock-and-fs_reclaim.patch