]> git.hungrycats.org Git - linux/commitdiff
ovl: fsync after copy-up
authorMiklos Szeredi <mszeredi@redhat.com>
Mon, 31 Oct 2016 13:42:14 +0000 (14:42 +0100)
committerSasha Levin <alexander.levin@verizon.com>
Thu, 24 Nov 2016 04:09:18 +0000 (23:09 -0500)
[ Upstream commit 641089c1549d8d3df0b047b5de7e9a111362cdce ]

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>
Cc: <stable@vger.kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
fs/overlayfs/copy_up.c

index 4cb1c10c7706407595846332c50f0ab88fe2c8c3..ca48dff09e19382ae8cba986cdb23c47bf6fe646 100644 (file)
@@ -129,6 +129,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);