]> git.baikalelectronics.ru Git - kernel.git/commit
cifs: fix writeback race with file that is growing
authorJeff Layton <jlayton@redhat.com>
Mon, 26 Nov 2012 14:48:41 +0000 (09:48 -0500)
committerSteve French <smfrench@gmail.com>
Tue, 27 Nov 2012 19:46:12 +0000 (13:46 -0600)
commit1460e98298eb6d9fe54abd2b35f15167eb121451
tree19230b635db898db1ca0661cbc4170fca9bccade
parentfad33011524e23bc51106083cec7ef60d8c00bab
cifs: fix writeback race with file that is growing

Commit 60e505359a4 created a regression in the writepages codepath.
Previously, whenever it needed to check the size of the file, it did so
by consulting the inode->i_size field directly. With that patch, the
i_size was fetched once on entry into the writepages code and that value
was used henceforth.

If the file is changing size though (for instance, if someone is writing
to it or has truncated it), then that value is likely to be wrong. This
can lead to data corruption. Pages past the EOF at the time that the
writepages call was issued may be silently dropped and ignored because
cifs_writepages wrongly assumes that the file must have been truncated
in the interim.

Fix cifs_writepages to properly fetch the size from the inode->i_size
field instead to properly account for this possibility.

Original bug report is here:

    https://bugzilla.kernel.org/show_bug.cgi?id=50991

Reported-and-Tested-by: Maxim Britov <ungifted01@gmail.com>
Reviewed-by: Suresh Jayaraman <sjayaraman@suse.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/file.c