From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36EDB8484 for ; Fri, 10 Mar 2023 14:05:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAA68C433EF; Fri, 10 Mar 2023 14:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678457107; bh=1eNf2rnF2+IQaObR/7MOkLchWxP3alFNsUiR4jI+jVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yadmCi8HCTgFu3BTpXrocaVWjhfcLykujfkWIXB0iRHz0dADpIec1JWBgEFTzJhq6 YAbWevNhX6oCzPrJXUlOnVDycuVkwW01g4tPth89cSUS6JGT6Hygz2Fb53mhw/hHh8 HxKLASX1nvBvtQCLaAEXQJeqGGvCxkQcJPkwmXQI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 6.1 022/200] f2fs: fix to abort atomic write only during do_exist() Date: Fri, 10 Mar 2023 14:37:09 +0100 Message-Id: <20230310133717.726789366@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310133717.050159289@linuxfoundation.org> References: <20230310133717.050159289@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Chao Yu [ Upstream commit ae267fc1cfe9f941afcb90dc963ee6448dae73cf ] Commit 7a10f0177e11 ("f2fs: don't give partially written atomic data from process crash") attempted to drop atomic write data after process crash, however, f2fs_abort_atomic_write() may be called from noncrash case, fix it by adding missed PF_EXITING check condition f2fs_file_flush(). - application crashs - do_exit - exit_signals -- sets PF_EXITING - exit_files - put_files_struct - close_files - filp_close - flush (f2fs_file_flush) - check atomic_write_task && PF_EXITING - f2fs_abort_atomic_write Fixes: 7a10f0177e11 ("f2fs: don't give partially written atomic data from process crash") Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 88eecd7149cd5..8a576c004b72a 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1879,7 +1879,8 @@ static int f2fs_file_flush(struct file *file, fl_owner_t id) * until all the writers close its file. Since this should be done * before dropping file lock, it needs to do in ->flush. */ - if (F2FS_I(inode)->atomic_write_task == current) + if (F2FS_I(inode)->atomic_write_task == current && + (current->flags & PF_EXITING)) f2fs_abort_atomic_write(inode, true); return 0; } -- 2.39.2