udf: Fix extending file within last block
authorJan Kara <jack@suse.cz>
Thu, 8 Dec 2022 12:03:30 +0000 (13:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jan 2023 11:07:11 +0000 (12:07 +0100)
commit9391da5e025dcf917d5cdd0f23d0bf0c722d77f2
tree6f14760f7b5ba02486236e1f32f413977cca6c3f
parent1f9eae31750287bdb1e200b16016be119090a400
udf: Fix extending file within last block

commit 1f3868f06855c97a4954c99b36f3fc9eb8f60326 upstream.

When extending file within last block it can happen that the extent is
already rounded to the blocksize and thus contains the offset we want to
grow up to. In such case we would mistakenly expand the last extent and
make it one block longer than it should be, exposing unallocated block
in a file and causing data corruption. Fix the problem by properly
detecting this case and bailing out.

CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/udf/inode.c