Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932784AbcKILEo (ORCPT ); Wed, 9 Nov 2016 06:04:44 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:53798 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932681AbcKILEk (ORCPT ); Wed, 9 Nov 2016 06:04:40 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miklos Szeredi Subject: [PATCH 4.4 36/69] ovl: fsync after copy-up Date: Wed, 9 Nov 2016 11:44:14 +0100 Message-Id: <20161109102902.635822914@linuxfoundation.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161109102901.127641653@linuxfoundation.org> References: <20161109102901.127641653@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 803 Lines: 31 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miklos Szeredi 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 --- fs/overlayfs/copy_up.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -139,6 +139,8 @@ static int ovl_copy_up_data(struct path len -= bytes; } + if (!error) + error = vfs_fsync(new_file, 0); fput(new_file); out_fput: fput(old_file);