This is a note to let you know that I've just added the patch titled udf: Truncate added extents on failed expansion to the 6.2-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: udf-truncate-added-extents-on-failed-expansion.patch and it can be found in the queue-6.2 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 70bfb3a8d661d4fdc742afc061b88a7f3fc9f500 Mon Sep 17 00:00:00 2001 From: Jan Kara <jack@xxxxxxx> Date: Thu, 15 Dec 2022 14:24:03 +0100 Subject: udf: Truncate added extents on failed expansion From: Jan Kara <jack@xxxxxxx> commit 70bfb3a8d661d4fdc742afc061b88a7f3fc9f500 upstream. When a file expansion failed because we didn't have enough space for indirect extents make sure we truncate extents created so far so that we don't leave extents beyond EOF. CC: stable@xxxxxxxxxxxxxxx Signed-off-by: Jan Kara <jack@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/udf/inode.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -521,8 +521,10 @@ static int udf_do_extend_file(struct ino } if (fake) { - udf_add_aext(inode, last_pos, &last_ext->extLocation, - last_ext->extLength, 1); + err = udf_add_aext(inode, last_pos, &last_ext->extLocation, + last_ext->extLength, 1); + if (err < 0) + goto out_err; count++; } else { struct kernel_lb_addr tmploc; @@ -556,7 +558,7 @@ static int udf_do_extend_file(struct ino err = udf_add_aext(inode, last_pos, &last_ext->extLocation, last_ext->extLength, 1); if (err) - return err; + goto out_err; count++; } if (new_block_bytes) { @@ -565,7 +567,7 @@ static int udf_do_extend_file(struct ino err = udf_add_aext(inode, last_pos, &last_ext->extLocation, last_ext->extLength, 1); if (err) - return err; + goto out_err; count++; } @@ -579,6 +581,11 @@ out: return -EIO; return count; +out_err: + /* Remove extents we've created so far */ + udf_clear_extent_cache(inode); + udf_truncate_extents(inode); + return err; } /* Extend the final block of the file to final_block_len bytes */ Patches currently in stable-queue which might be from jack@xxxxxxx are queue-6.2/udf-fix-file-corruption-when-appending-just-after-end-of-preallocated-extent.patch queue-6.2/sbitmap-correct-wake_batch-recalculation-to-avoid-po.patch queue-6.2/udf-do-not-update-file-length-for-failed-writes-to-inline-files.patch queue-6.2/udf-truncate-added-extents-on-failed-expansion.patch queue-6.2/udf-detect-system-inodes-linked-into-directory-hierarchy.patch queue-6.2/udf-do-not-bother-merging-very-long-extents.patch queue-6.2/udf-define-efscorrupted-error-code.patch queue-6.2/sbitmap-remove-redundant-check-in-__sbitmap_queue_ge.patch queue-6.2/udf-preserve-link-count-of-system-files.patch