Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

udf: fix silent AED tagLocation corruption

When extending a file, udf_do_extend_file() may enter following empty
indirect extent. At the end of udf_do_extend_file() we revert prev_epos
to point to the last written extent. However if we end up not adding any
further extent in udf_do_extend_file(), the reverting points prev_epos
into the header area of the AED and following updates of the extents
(in udf_update_extents()) will corrupt the header.

Make sure that we do not follow indirect extent if we are not going to
add any more extents so that returning back to the last written extent
works correctly.

Link: https://lore.kernel.org/r/20210107234116.6190-2-magnani@ieee.org
Signed-off-by: Steven J. Magnani <magnani@ieee.org>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Steven J. Magnani and committed by
Jan Kara
63c9e47a 0a6dc67a

+6 -3
+6 -3
fs/udf/inode.c
··· 544 544 545 545 udf_write_aext(inode, last_pos, &last_ext->extLocation, 546 546 last_ext->extLength, 1); 547 + 547 548 /* 548 - * We've rewritten the last extent but there may be empty 549 - * indirect extent after it - enter it. 549 + * We've rewritten the last extent. If we are going to add 550 + * more extents, we may need to enter possible following 551 + * empty indirect extent. 550 552 */ 551 - udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0); 553 + if (new_block_bytes || prealloc_len) 554 + udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0); 552 555 } 553 556 554 557 /* Managed to do everything necessary? */