FAILED: patch "[PATCH] btrfs: take commit root semaphore when iterating in" 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 0594e3423f4ba3137c734371169491f9a98e9af4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026092246-darkened-imminent-3978@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0594e3423f4ba3137c734371169491f9a98e9af4 Mon Sep 17 00:00:00 2001
From: Hongling Zeng <[email protected]>
Date: Mon, 31 Aug 2026 13:38:01 +0800
Subject: [PATCH] btrfs: take commit root semaphore when iterating in
mark_block_group_to_copy()
mark_block_group_to_copy() iterates over the commit root with skip_locking=true. A concurrent transaction commit can swap and free the commit root during iteration, causing use-after-free when accessing extent buffers.
Fix it by using path->need_commit_sem to protect the commit root search.
fs/btrfs/dev-replace.c +1 -0
@@ -493,6 +493,7 @@ static int mark_block_group_to_copy(struct btrfs_fs_info *fs_info, path->reada =READA_FORWARD ; path->search_commit_root = true; path->skip_locking = true; + path->need_commit_sem = true; key.objectid = src_dev->devid; key.type =BTRFS_DEV_EXTENT_KEY ;
Sasha Levin
maintainerPATCH 1/1 btrfs: take commit root semaphore when iterating in mark_block_group_to_copy()
From: Hongling Zeng <[email protected]>
[ Upstream commit 0594e3423f4ba3137c734371169491f9a98e9af4 ]
mark_block_group_to_copy() iterates over the commit root with skip_locking=true. A concurrent transaction commit can swap and free the commit root during iteration, causing use-after-free when accessing extent buffers.
Fix it by using path->need_commit_sem to protect the commit root search.
--- fs/btrfs/dev-replace.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/dev-replace.c +1 -0
@@ -520,6 +520,7 @@ static int mark_block_group_to_copy(struct btrfs_fs_info *fs_info, path->reada =READA_FORWARD ; path->search_commit_root =1 ; path->skip_locking =1 ; + path->need_commit_sem =1 ; key.objectid = src_dev->devid; key.type =BTRFS_DEV_EXTENT_KEY ;
Signature · 1 line
2.53.0