Skip to content

Commit

Permalink
iomap: Fix possible overflow condition in iomap_write_delalloc_scan
Browse files Browse the repository at this point in the history
folio_next_index() returns an unsigned long value which left shifted
by PAGE_SHIFT could possibly cause an overflow on 32-bit system. Instead
use folio_pos(folio) + folio_size(folio), which does this correctly.

Suggested-by: Matthew Wilcox <[email protected]>
Signed-off-by: Ritesh Harjani (IBM) <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
  • Loading branch information
riteshharjani committed Jul 25, 2023
1 parent cc86181 commit eee2d2e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/iomap/buffered-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ static int iomap_write_delalloc_scan(struct inode *inode,
* the end of this data range, not the end of the folio.
*/
*punch_start_byte = min_t(loff_t, end_byte,
folio_next_index(folio) << PAGE_SHIFT);
folio_pos(folio) + folio_size(folio));
}

/* move offset to start of next folio in range */
Expand Down

0 comments on commit eee2d2e

Please sign in to comment.