Skip to contentSkip to conversation

Patch "xfs: fix temporary cursor leak in btree shift corruption paths" has been added to the 6.18-stable tree

PATCH Sasha Levin 1 participant 1 message Nov 10 XFS filesystem

lore
Share & tools
lore

Sasha Levin

author Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

xfs: fix temporary cursor leak in btree shift corruption paths

to the 6.18-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
xfs-fix-temporary-cursor-leak-in-btree-shift-corrupt.patch
and it can be found in the queue-6.18 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

commit 4318d42de04df2e8615eae782e34cb539e9d88d4

Author: Jianyun Gao <[email protected]>
Date:   Mon Nov 2 23:01:41 2026 +0800

xfs: fix temporary cursor leak in btree shift corruption paths

[ Upstream commit 2bbca049deeb1699cafd966cb2793fee576ee409 ]

In xfs_btree_lshift and xfs_btree_rshift, when XFS_IS_CORRUPT detects an invalid firstrec/lastrec result after xfs_btree_dup_cursor has successfully allocated a temporary cursor, the error path jumps to error0 which returns without freeing tcur. This leaks the cursor memory, the xfs_group reference, and the per-level buffer references held by the duplicated cursor. Jump to error1 instead, which calls xfs_btree_del_cursor(tcur, XFS_BTREE_ERROR) to properly release all resources.

Fixes 9eaead51bed95 ("[XFS] implement generic xfs_btree_rshift")
fs/xfs/libxfs/xfs_btree.c +2 -2
index dbe9df8c33004..b0824d381e7c6 100644
@@ -2567,7 +2567,7 @@ xfs_btree_lshift(
 		if (XFS_IS_CORRUPT(tcur->bc_mp, i != 1)) {
 			xfs_btree_mark_sick(cur);
 			error = -EFSCORRUPTED;
-			goto error0;
+			goto error1;
 		}
 
 		error = xfs_btree_decrement(tcur, level, &i);
@@ -2737,7 +2737,7 @@ xfs_btree_rshift(
 	if (XFS_IS_CORRUPT(tcur->bc_mp, i != 1)) {
 		xfs_btree_mark_sick(cur);
 		error = -EFSCORRUPTED;
-		goto error0;
+		goto error1;
 	}
 
 	error = xfs_btree_increment(tcur, level, &i);