summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2016-10-31 14:42:14 +0100
committerSasha Levin <alexander.levin@verizon.com>2016-11-25 22:57:03 -0500
commit83a474ed7003b7065d3816d84dd0168f02a0ee94 (patch)
treeab1a3e627d775868e709dad18240e9fd8230b1d1 /fs
parentc0b309f18b0144aca3a0abc7fbaa5ab0dc82394c (diff)
ovl: fsync after copy-up
[ 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>
Diffstat (limited to 'fs')
-rw-r--r--fs/overlayfs/copy_up.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 4d8aa749d9b2..c57cd417802b 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -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);