Patch "btrfs: handle invalid root reference found in may_destroy_subvol()" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

    btrfs: handle invalid root reference found in may_destroy_subvol()

to the 5.4-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-handle-invalid-root-reference-found-in-may_des.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 6901235e32bc4282eeb22ebdcfab84d0e23dda9b
Author: David Sterba <dsterba@xxxxxxxx>
Date:   Wed Jan 24 22:58:01 2024 +0100

    btrfs: handle invalid root reference found in may_destroy_subvol()
    
    [ Upstream commit 6fbc6f4ac1f4907da4fc674251527e7dc79ffbf6 ]
    
    The may_destroy_subvol() looks up a root by a key, allowing to do an
    inexact search when key->offset is -1.  It's never expected to find such
    item, as it would break the allowed range of a root id.
    
    Signed-off-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2c86be3fc25cd..d2a988bf9c895 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4520,7 +4520,14 @@ static noinline int may_destroy_subvol(struct btrfs_root *root)
 	ret = btrfs_search_slot(NULL, fs_info->tree_root, &key, path, 0, 0);
 	if (ret < 0)
 		goto out;
-	BUG_ON(ret == 0);
+	if (ret == 0) {
+		/*
+		 * Key with offset -1 found, there would have to exist a root
+		 * with such id, but this is out of valid range.
+		 */
+		ret = -EUCLEAN;
+		goto out;
+	}
 
 	ret = 0;
 	if (path->slots[0] > 0) {




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux