From: Miklos Szeredi Date: Mon, 31 Oct 2016 13:42:14 +0000 (+0100) Subject: ovl: fsync after copy-up X-Git-Tag: firefly_0821_release~176^2~4^2~19^2~34 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e3d312c435dd98a8b7a8dbaca9568f20449d5e47;p=firefly-linux-kernel-4.4.55.git ovl: fsync after copy-up commit 641089c1549d8d3df0b047b5de7e9a111362cdce upstream. Make sure the copied up file hits the disk before renaming to the final destination. If this is not done then the copy-up may corrupt the data in the file in case of a crash. Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index ea0dd9ee138d..63a0d0ba36de 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -139,6 +139,8 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len) len -= bytes; } + if (!error) + error = vfs_fsync(new_file, 0); fput(new_file); out_fput: fput(old_file);