From: "Sungjong Seo" <sj1557.seo@samsung.com>
To: "'Jaewook Kim'" <jw5454.kim@samsung.com>, <jaegeuk@kernel.org>,
<chao@kernel.org>
Cc: <linux-f2fs-devel@lists.sourceforge.net>,
<linux-kernel@vger.kernel.org>, <junbeom.yeom@samsung.com>,
<youngjin.gil@samsung.com>, <sj1557.seo@samsung.com>
Subject: RE: [PATCH] f2fs: do not allow to decompress files have FI_COMPRESS_RELEASED
Date: Wed, 3 Aug 2022 12:45:48 +0900 [thread overview]
Message-ID: <25e501d8a6eb$84cf4090$8e6dc1b0$@samsung.com> (raw)
In-Reply-To: <20220803023431.30214-1-jw5454.kim@samsung.com>
> If a file has FI_COMPRESS_RELEASED, all writes for it should not be
> allowed. However, as of now, in case of compress_mode=user, writes
> triggered by IOCTLs like F2FS_IOC_DE/COMPRESS_FILE are allowed unexpectly,
> which could crash that file.
> To fix it, let's do not allow F2FS_IOC_DE/COMPRESS_IOCTL if a file already
> has FI_COMPRESS_RELEASED flag.
>
> This is the reproduction process:
> 1. $ chattr +c ./file
> 2. $ dd if=/dev/zero of=./file bs=4096 count=2000 oflag=append
> conv=notrunc 3. $ sync
> 4. $ do_compress ./file ; call F2FS_IOC_COMPRESS_FILE
> 5. $ get_compr_blocks ./file ; call F2FS_IOC_GET_COMPRESS_BLOCKS
Oops! Do we need to call F2FS_IOC_RELEASE_COMPRESS_BLOCKS here?
Maybe, you need to revise reproduction process and to make v2 patch.
> 6. $ do_compress ./file ; call F2FS_IOC_COMPRESS_FILE again
> 7. $ get_compr_blocks ./file ; call F2FS_IOC_GET_COMPRESS_BLOCKS again
>
> You can find compr_blocks has a negative value.
>
> Fixes: 5fdb322ff2c2b ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and
> F2FS_IOC_COMPRESS_FILE")
>
> Signed-off-by: Junbeom Yeom <junbeom.yeom@samsung.com>
> Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com>
> Signed-off-by: Youngjin Gil <youngjin.gil@samsung.com>
> Signed-off-by: Jaewook Kim <jw5454.kim@samsung.com>
> ---
> fs/f2fs/file.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index
> 6b1b030830ca..a4713b7e12cb 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -3945,6 +3945,11 @@ static int f2fs_ioc_decompress_file(struct file
> *filp, unsigned long arg)
> goto out;
> }
>
> + if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
> + ret = -EINVAL;
> + goto out;
> + }
> +
> ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX);
> if (ret)
> goto out;
> @@ -4012,6 +4017,11 @@ static int f2fs_ioc_compress_file(struct file *filp,
> unsigned long arg)
> goto out;
> }
>
> + if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
> + ret = -EINVAL;
> + goto out;
> + }
> +
> ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX);
> if (ret)
> goto out;
> --
> 2.17.1
next prev parent reply other threads:[~2022-08-03 3:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220803023449epcas1p4a9b09cdc73878c8ee40ae10523279dc3@epcas1p4.samsung.com>
2022-08-03 2:34 ` [PATCH] f2fs: do not allow to decompress files have FI_COMPRESS_RELEASED Jaewook Kim
2022-08-03 3:45 ` Sungjong Seo [this message]
2022-08-03 8:53 ` [PATCH v2] " Jaewook Kim
2022-08-04 13:32 ` Chao Yu
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='25e501d8a6eb$84cf4090$8e6dc1b0$@samsung.com' \
--to=sj1557.seo@samsung.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=junbeom.yeom@samsung.com \
--cc=jw5454.kim@samsung.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=youngjin.gil@samsung.com \
/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