From: Greg Kroah-Hartman Date: Sun, 9 May 2021 09:58:29 +0000 (+0200) Subject: drop queue-5.4/btrfs-fix-a-potential-hole-punching-failure.patch X-Git-Tag: v5.4.118~55 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ecfbdb0ea2d1354963994a5d0d814f73109af2c9;p=thirdparty%2Fkernel%2Fstable-queue.git drop queue-5.4/btrfs-fix-a-potential-hole-punching-failure.patch --- diff --git a/queue-5.4/btrfs-fix-a-potential-hole-punching-failure.patch b/queue-5.4/btrfs-fix-a-potential-hole-punching-failure.patch deleted file mode 100644 index 3df750dde70..00000000000 --- a/queue-5.4/btrfs-fix-a-potential-hole-punching-failure.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 3744bdfd37eaa635ddb70f15fe5d3bde233e54f0 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Thu, 25 Mar 2021 09:56:22 +0800 -Subject: btrfs: fix a potential hole punching failure - -From: BingJing Chang - -[ Upstream commit 3227788cd369d734d2d3cd94f8af7536b60fa552 ] - -In commit d77815461f04 ("btrfs: Avoid trucating page or punching hole -in a already existed hole."), existing holes can be skipped by calling -find_first_non_hole() to adjust start and len. However, if the given len -is invalid and large, when an EXTENT_MAP_HOLE extent is found, len will -not be set to zero because (em->start + em->len) is less than -(start + len). Then the ret will be 1 but len will not be set to 0. -The propagated non-zero ret will result in fallocate failure. - -In the while-loop of btrfs_replace_file_extents(), len is not updated -every time before it calls find_first_non_hole(). That is, after -btrfs_drop_extents() successfully drops the last non-hole file extent, -it may fail with ENOSPC when attempting to drop a file extent item -representing a hole. The problem can happen. After it calls -find_first_non_hole(), the cur_offset will be adjusted to be larger -than or equal to end. However, since the len is not set to zero, the -break-loop condition (ret && !len) will not be met. After it leaves the -while-loop, fallocate will return 1, which is an unexpected return -value. - -We're not able to construct a reproducible way to let -btrfs_drop_extents() fail with ENOSPC after it drops the last non-hole -file extent but with remaining holes left. However, it's quite easy to -fix. We just need to update and check the len every time before we call -find_first_non_hole(). To make the while loop more readable, we also -pull the variable updates to the bottom of loop like this: - while (cur_offset < end) { - ... - // update cur_offset & len - // advance cur_offset & len in hole-punching case if needed - } - -Reported-by: Robbie Ko -Fixes: d77815461f04 ("btrfs: Avoid trucating page or punching hole in a already existed hole.") -CC: stable@vger.kernel.org # 4.4+ -Reviewed-by: Robbie Ko -Reviewed-by: Chung-Chiang Cheng -Reviewed-by: Filipe Manana -Signed-off-by: BingJing Chang -Signed-off-by: David Sterba -Signed-off-by: Sasha Levin ---- - fs/btrfs/file.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c -index f8e5c47b95e4..dc6f4bfd9a45 100644 ---- a/fs/btrfs/file.c -+++ b/fs/btrfs/file.c -@@ -2642,8 +2642,6 @@ int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path, - clone_info->file_offset += clone_len; - } - -- cur_offset = drop_end; -- - ret = btrfs_update_inode(trans, root, inode); - if (ret) - break; -@@ -2663,7 +2661,9 @@ int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path, - BUG_ON(ret); /* shouldn't happen */ - trans->block_rsv = rsv; - -- if (!clone_info) { -+ cur_offset = drop_args.drop_end; -+ len = end - cur_offset; -+ if (!clone_info && len) { - ret = find_first_non_hole(inode, &cur_offset, &len); - if (unlikely(ret < 0)) - break; --- -2.30.2 - diff --git a/queue-5.4/series b/queue-5.4/series index 7299b3aef89..47af0769155 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -133,5 +133,4 @@ alsa-hda-realtek-fix-mic-boost-on-intel-nuc-8.patch alsa-hda-realtek-fix-static-noise-on-alc285-lenovo-laptops.patch alsa-hda-realtek-add-quirk-for-intel-clevo-pcx0dx.patch btrfs-fix-race-when-picking-most-recent-mod-log-oper.patch -btrfs-fix-a-potential-hole-punching-failure.patch arm64-vdso-discard-.note.gnu.property-sections-in-vd.patch