Patch "btrfs: handle memory allocation failure in btrfs_csum_one_bio" has been added to the 6.3-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 memory allocation failure in btrfs_csum_one_bio

to the 6.3-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-memory-allocation-failure-in-btrfs_csum.patch
and it can be found in the queue-6.3 subdirectory.

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



commit 5e561b2044a7a50df7c05016ce7f3b22162a00f3
Author: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
Date:   Thu May 4 13:58:13 2023 +0200

    btrfs: handle memory allocation failure in btrfs_csum_one_bio
    
    [ Upstream commit 806570c0bb7b4847828c22c4934fcf2dc8fc572f ]
    
    Since f8a53bb58ec7 ("btrfs: handle checksum generation in the storage
    layer") the failures of btrfs_csum_one_bio() are handled via
    bio_end_io().
    
    This means, we can return BLK_STS_RESOURCE from btrfs_csum_one_bio() in
    case the allocation of the ordered sums fails.
    
    This also fixes a syzkaller report, where injecting a failure into the
    kvzalloc() call results in a BUG_ON().
    
    Reported-by: syzbot+d8941552e21eac774778@xxxxxxxxxxxxxxxxxxxxxxxxx
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Reviewed-by: Anand Jain <anand.jain@xxxxxxxxxx>
    Signed-off-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
    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/file-item.c b/fs/btrfs/file-item.c
index a4584c629ba35..9e45b416a9c85 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -847,7 +847,9 @@ blk_status_t btrfs_csum_one_bio(struct btrfs_bio *bbio)
 				sums = kvzalloc(btrfs_ordered_sum_size(fs_info,
 						      bytes_left), GFP_KERNEL);
 				memalloc_nofs_restore(nofs_flag);
-				BUG_ON(!sums); /* -ENOMEM */
+				if (!sums)
+					return BLK_STS_RESOURCE;
+
 				sums->len = bytes_left;
 				ordered = btrfs_lookup_ordered_extent(inode,
 								offset);



[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