]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ovl: fsync after copy-up
authorMiklos Szeredi <mszeredi@redhat.com>
Mon, 31 Oct 2016 13:42:14 +0000 (14:42 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2016 15:38:51 +0000 (16:38 +0100)
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 <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/overlayfs/copy_up.c

index abadbc30e013ab5520d8e2853178f02504d196fb..767377e522c676c9ccedd88544bbdd28e40ffac8 100644 (file)
@@ -171,6 +171,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);