Skip to content

Commit e28ae8e

Browse files
Christoph Hellwigdjwong
authored andcommitted
iomap: fix integer truncation issues in the zeroing and dirtying helpers
Fix the min_t calls in the zeroing and dirtying helpers to perform the comparisms on 64-bit types, which prevents them from incorrectly being truncated, and larger zeroing operations being stuck in a never ending loop. Special thanks to Markus Stockhausen for spotting the bug. Reported-by: Paul Menzel <pmenzel@molgen.mpg.de> Tested-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
1 parent c44245b commit e28ae8e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/iomap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
278278
unsigned long bytes; /* Bytes to write to page */
279279

280280
offset = (pos & (PAGE_SIZE - 1));
281-
bytes = min_t(unsigned long, PAGE_SIZE - offset, length);
281+
bytes = min_t(loff_t, PAGE_SIZE - offset, length);
282282

283283
rpage = __iomap_read_page(inode, pos);
284284
if (IS_ERR(rpage))
@@ -373,7 +373,7 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count,
373373
unsigned offset, bytes;
374374

375375
offset = pos & (PAGE_SIZE - 1); /* Within page */
376-
bytes = min_t(unsigned, PAGE_SIZE - offset, count);
376+
bytes = min_t(loff_t, PAGE_SIZE - offset, count);
377377

378378
if (IS_DAX(inode))
379379
status = iomap_dax_zero(pos, offset, bytes, iomap);

0 commit comments

Comments
 (0)