Add patches to fix kernel crashes on corrupted file systems
[ext4-patch-queue.git] / ext4-fix-mmap-data-corruption-when-blocksize-lt-pagesize
blobfc56b546062d5d40b0a82af2f8f1965f6e07604e
1 ext4: fix mmap data corruption when blocksize < pagesize
3 From: Jan Kara <jack@suse.cz>
5 Use truncate_isize_extended() when hole is being created in a file so that
6 ->page_mkwrite() will get called for the partial tail page if it is
7 mmaped (see the first patch in the series for details).
9 Signed-off-by: Jan Kara <jack@suse.cz>
10 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
11 ---
12  fs/ext4/inode.c | 6 +++++-
13  1 file changed, 5 insertions(+), 1 deletion(-)
15 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
16 index 3aa26e9117c4..9e269489e094 100644
17 --- a/fs/ext4/inode.c
18 +++ b/fs/ext4/inode.c
19 @@ -4536,8 +4536,12 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
20                                 ext4_orphan_del(NULL, inode);
21                                 goto err_out;
22                         }
23 -               } else
24 +               } else {
25 +                       loff_t oldsize = inode->i_size;
27                         i_size_write(inode, attr->ia_size);
28 +                       pagecache_isize_extended(inode, oldsize, inode->i_size);
29 +               }
31                 /*
32                  * Blocks are going to be removed from the inode. Wait
33 -- 
34 1.8.1.4
37 To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
38 the body of a message to majordomo@vger.kernel.org
39 More majordomo info at  http://vger.kernel.org/majordomo-info.html