Patch "btrfs: add a sanity check for btrfs root in btrfs_search_slot()" has been added to the 5.15-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: add a sanity check for btrfs root in btrfs_search_slot()

to the 5.15-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-add-a-sanity-check-for-btrfs-root-in-btrfs_sea.patch
and it can be found in the queue-5.15 subdirectory.

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



commit f3feb84458850475627d283399fc095cfd3e8097
Author: Lizhi Xu <lizhi.xu@xxxxxxxxxxxxx>
Date:   Fri Oct 25 12:55:53 2024 +0800

    btrfs: add a sanity check for btrfs root in btrfs_search_slot()
    
    [ Upstream commit 3ed51857a50f530ac7a1482e069dfbd1298558d4 ]
    
    Syzbot reports a null-ptr-deref in btrfs_search_slot().
    
    The reproducer is using rescue=ibadroots, and the extent tree root is
    corrupted thus the extent tree is NULL.
    
    When scrub tries to search the extent tree to gather the needed extent
    info, btrfs_search_slot() doesn't check if the target root is NULL or
    not, resulting the null-ptr-deref.
    
    Add sanity check for btrfs root before using it in btrfs_search_slot().
    
    Reported-by: syzbot+3030e17bd57a73d39bd7@xxxxxxxxxxxxxxxxxxxxxxxxx
    Fixes: 42437a6386ff ("btrfs: introduce mount option rescue=ignorebadroots")
    Link: https://syzkaller.appspot.com/bug?extid=3030e17bd57a73d39bd7
    CC: stable@xxxxxxxxxxxxxxx # 5.15+
    Reviewed-by: Qu Wenruo <wqu@xxxxxxxx>
    Tested-by: syzbot+3030e17bd57a73d39bd7@xxxxxxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Lizhi Xu <lizhi.xu@xxxxxxxxxxxxx>
    Reviewed-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index af6ddf1f913ae..345f205af6198 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1763,7 +1763,7 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 		      const struct btrfs_key *key, struct btrfs_path *p,
 		      int ins_len, int cow)
 {
-	struct btrfs_fs_info *fs_info = root->fs_info;
+	struct btrfs_fs_info *fs_info;
 	struct extent_buffer *b;
 	int slot;
 	int ret;
@@ -1776,6 +1776,10 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 	int min_write_lock_level;
 	int prev_cmp;
 
+	if (!root)
+		return -EINVAL;
+
+	fs_info = root->fs_info;
 	might_sleep();
 
 	lowest_level = p->lowest_level;




[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