Skip to content

Commit b9b4bb2

Browse files
Anthony Romanotorvalds
authored andcommitted
tmpfs: don't undo fallocate past its last page
When fallocate is interrupted it will undo a range that extends one byte past its range of allocated pages. This can corrupt an in-use page by zeroing out its first byte. Instead, undo using the inclusive byte range. Fixes: 1635f6a ("tmpfs: undo fallocation on failure") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Anthony Romano <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Brandon Philips <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a7b50ab commit b9b4bb2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/shmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
22272227
/* Remove the !PageUptodate pages we added */
22282228
shmem_undo_range(inode,
22292229
(loff_t)start << PAGE_SHIFT,
2230-
(loff_t)index << PAGE_SHIFT, true);
2230+
((loff_t)index << PAGE_SHIFT) - 1, true);
22312231
goto undone;
22322232
}
22332233

0 commit comments

Comments
 (0)