Skip to content

Commit c2a09f3

Browse files
riteshharjanitytso
authored andcommitted
ext4: Fixes len calculation in mpage_journal_page_buffers
Truncate operation can race with writeback, in which inode->i_size can get truncated and therefore size - folio_pos() can be negative. This fixes the len calculation. However this path doesn't get easily triggered even with data journaling. Cc: stable@kernel.org # v6.5 Fixes: 80be8c5 ("Fixes: ext4: Make mpage_journal_page_buffers use folio") Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/cff4953b5c9306aba71e944ab176a5d396b9a1b7.1709182250.git.ritesh.list@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 0bbac3f commit c2a09f3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/ext4/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2334,7 +2334,7 @@ static int mpage_journal_page_buffers(handle_t *handle,
23342334

23352335
if (folio_pos(folio) + len > size &&
23362336
!ext4_verity_in_progress(inode))
2337-
len = size - folio_pos(folio);
2337+
len = size & (len - 1);
23382338

23392339
return ext4_journal_folio_buffers(handle, folio, len);
23402340
}

0 commit comments

Comments
 (0)