]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: handle memory allocation failure in btrfs_csum_one_bio
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Thu, 4 May 2023 11:58:13 +0000 (13:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Jun 2023 14:02:06 +0000 (16:02 +0200)
commit38cb20b671954a3a6e293a1d376ddeff608b12de
treebce65a4a478c99a9d889145027946ae1679e16e0
parenta96cad9a4771233b2b61036020b8e80158c441ae
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@syzkaller.appspotmail.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/file-item.c