linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>, Jaegeuk Kim <jaegeuk@kernel.org>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH AUTOSEL 5.9 014/147] f2fs: compress: fix to disallow enabling compress on non-empty file
Date: Mon, 26 Oct 2020 19:46:52 -0400	[thread overview]
Message-ID: <20201026234905.1022767-14-sashal@kernel.org> (raw)
In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org>

From: Chao Yu <yuchao0@huawei.com>

[ Upstream commit 519a5a2f37b850f4eb86674a10d143088670a390 ]

Compressed inode and normal inode has different layout, so we should
disallow enabling compress on non-empty file to avoid race condition
during inode .i_addr array parsing and updating.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
[Jaegeuk Kim: Fix missing condition]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/f2fs/file.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 8a422400e824d..4ec10256dc67f 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1836,6 +1836,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
 		if (iflags & F2FS_COMPR_FL) {
 			if (!f2fs_may_compress(inode))
 				return -EINVAL;
+			if (S_ISREG(inode->i_mode) && inode->i_size)
+				return -EINVAL;
 
 			set_compress_context(inode);
 		}
-- 
2.25.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  parent reply	other threads:[~2020-10-26 23:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201026234905.1022767-1-sashal@kernel.org>
2020-10-26 23:46 ` [f2fs-dev] [PATCH AUTOSEL 5.9 004/147] f2fs: allocate proper size memory for zstd decompress Sasha Levin
2020-10-26 23:46 ` [f2fs-dev] [PATCH AUTOSEL 5.9 009/147] f2fs: add trace exit in exception path Sasha Levin
2020-10-26 23:46 ` [f2fs-dev] [PATCH AUTOSEL 5.9 010/147] f2fs: do sanity check on zoned block device path Sasha Levin
2020-10-26 23:46 ` [f2fs-dev] [PATCH AUTOSEL 5.9 011/147] f2fs: fix uninit-value in f2fs_lookup Sasha Levin
2020-10-26 23:46 ` [f2fs-dev] [PATCH AUTOSEL 5.9 012/147] f2fs: fix to check segment boundary during SIT page readahead Sasha Levin
2020-10-26 23:46 ` Sasha Levin [this message]
2020-10-26 23:46 ` [f2fs-dev] [PATCH AUTOSEL 5.9 017/147] f2fs: handle errors of f2fs_get_meta_page_nofail Sasha Levin
2020-10-26 23:48 ` [f2fs-dev] [PATCH AUTOSEL 5.9 106/147] f2fs: fix to set SBI_NEED_FSCK flag for inconsistent inode Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201026234905.1022767-14-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).