This is a note to let you know that I've just added the patch titled btrfs: send: handle unexpected inode in header process_recorded_refs() to the 6.6-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: btrfs-send-handle-unexpected-inode-in-header-process.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 11aca56b46f527e5ac39c3d1f875bbcbfb70809d Author: David Sterba <dsterba@xxxxxxxx> Date: Tue Feb 6 22:47:13 2024 +0100 btrfs: send: handle unexpected inode in header process_recorded_refs() [ Upstream commit 5d2288711ccc483feca73151c46ee835bda17839 ] Change BUG_ON to proper error handling when an unexpected inode number is encountered. As the comment says this should never happen. Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index b153f6a96fc8c..9da3c72eb6153 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4195,7 +4195,13 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) * This should never happen as the root dir always has the same ref * which is always '..' */ - BUG_ON(sctx->cur_ino <= BTRFS_FIRST_FREE_OBJECTID); + if (unlikely(sctx->cur_ino <= BTRFS_FIRST_FREE_OBJECTID)) { + btrfs_err(fs_info, + "send: unexpected inode %llu in process_recorded_refs()", + sctx->cur_ino); + ret = -EINVAL; + goto out; + } valid_path = fs_path_alloc(); if (!valid_path) {