summaryrefslogtreecommitdiff
path: root/fs/ubifs/file.c
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2020-01-16 17:12:00 -0800
committerDarrick J. Wong <darrick.wong@oracle.com>2020-01-31 12:47:23 -0800
commit209bc3abf87d1c6bac1c8729245a3173913a8ab9 (patch)
tree08fedc12be01c10e908fd5485ed182d42db9f240 /fs/ubifs/file.c
parent357ecc5f95d2a06bfeb683053f5e4c522b93c284 (diff)
fs: Fix page_mkwrite off-by-one errorsxfs-5.6-merge_2020-01-31
Hi Darrick, here's an updated version with the latest feedback incorporated. Hope you find that useful. As far as the f2fs merge conflict goes, I've been told by Linus not to resolve those kinds of conflicts but to point them out when sending the merge request. So this shouldn't be a big deal. Changes: * Turn page_mkwrite_check_truncate into a non-inline function. * Get rid of now-unused mapping variable in ext4_page_mkwrite. * In btrfs_page_mkwrite, don't ignore the return value of block_page_mkwrite_return (no change in behavior). * Clean up the f2fs_vm_page_mkwrite changes as suggested by Jaegeuk Kim. Thanks, Andreas -- The check in block_page_mkwrite that is meant to determine whether an offset is within the inode size is off by one. This bug has been copied into iomap_page_mkwrite and several filesystems (ubifs, ext4, f2fs, ceph). Fix that by introducing a new page_mkwrite_check_truncate helper that checks for truncate and computes the bytes in the page up to EOF. Use the helper in the above mentioned filesystems. In addition, use the new helper in btrfs as well. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Acked-by: David Sterba <dsterba@suse.com> (btrfs) Acked-by: Richard Weinberger <richard@nod.at> (ubifs) Acked-by: Theodore Ts'o <tytso@mit.edu> (ext4) Acked-by: Chao Yu <yuchao0@huawei.com> (f2fs) Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/ubifs/file.c')
-rw-r--r--fs/ubifs/file.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index cd52585c8f4f..91f7a1f2db0d 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1563,8 +1563,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
}
lock_page(page);
- if (unlikely(page->mapping != inode->i_mapping ||
- page_offset(page) > i_size_read(inode))) {
+ if (unlikely(page_mkwrite_check_truncate(page, inode) < 0)) {
/* Page got truncated out from underneath us */
goto sigbus;
}