Skip to content

Commit d3c51c5

Browse files
author
Andreas Gruenbacher
committed
gfs2: Fix underflow in gfs2_page_mkwrite
On filesystems with a block size smaller than PAGE_SIZE and non-empty files smaller then PAGE_SIZE, gfs2_page_mkwrite could end up allocating excess blocks beyond the end of the file, similar to fallocate. This doesn't make sense; fix it. Reported-by: Bob Peterson <[email protected]> Fixes: 184b4e6 ("gfs2: Fix end-of-file handling in gfs2_page_mkwrite") Cc: [email protected] # v5.5+ Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 38a618d commit d3c51c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/gfs2/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)
450450
file_update_time(vmf->vma->vm_file);
451451

452452
/* page is wholly or partially inside EOF */
453-
if (offset > size - PAGE_SIZE)
454-
length = offset_in_page(size);
453+
if (size - offset < PAGE_SIZE)
454+
length = size - offset;
455455
else
456456
length = PAGE_SIZE;
457457

0 commit comments

Comments
 (0)