Skip to content

Commit

Permalink
tmpfs: don't undo fallocate past its last page
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Anthony Romano authored and torvalds committed Jun 25, 2016
1 parent a7b50ab commit b9b4bb2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
/* Remove the !PageUptodate pages we added */
shmem_undo_range(inode,
(loff_t)start << PAGE_SHIFT,
(loff_t)index << PAGE_SHIFT, true);
((loff_t)index << PAGE_SHIFT) - 1, true);
goto undone;
}

Expand Down

0 comments on commit b9b4bb2

Please sign in to comment.