ext4: fix data corruption in data=journal mode
authorJan Kara <jack@suse.cz>
Fri, 27 Jan 2017 19:35:38 +0000 (14:35 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 12 Mar 2017 05:37:27 +0000 (06:37 +0100)
commit9d636818dbac53c07c1bf7aa006c06ec32253187
tree333cae7e88df59e85a88aebb4f45bee5aaf64f5a
parent8774c73cf6963310395823ed7077ea12943ea0f3
ext4: fix data corruption in data=journal mode

commit 3b136499e906460919f0d21a49db1aaccf0ae963 upstream.

ext4_journalled_write_end() did not propely handle all the cases when
generic_perform_write() did not copy all the data into the target page
and could mark buffers with uninitialized contents as uptodate and dirty
leading to possible data corruption (which would be quickly fixed by
generic_perform_write() retrying the write but still). Fix the problem
by carefully handling the case when the page that is written to is not
uptodate.

Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/inode.c