Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934392AbcKILPb (ORCPT ); Wed, 9 Nov 2016 06:15:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:56326 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933460AbcKILP1 (ORCPT ); Wed, 9 Nov 2016 06:15:27 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miklos Szeredi Subject: [PATCH 4.8 078/138] ovl: fsync after copy-up Date: Wed, 9 Nov 2016 11:46:01 +0100 Message-Id: <20161109102848.438910579@linuxfoundation.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161109102844.808685475@linuxfoundation.org> References: <20161109102844.808685475@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.8-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 @@ -171,6 +171,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);