linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/2] f2fs: compress: fix to relocate check condition in f2fs_{release, reserve}_compress_blocks()
@ 2024-04-07  7:26 Chao Yu
  2024-04-07  7:26 ` [f2fs-dev] [PATCH 2/2] f2fs: compress: fix to relocate check condition in f2fs_ioc_{, de}compress_file() Chao Yu
  2024-04-14 15:32 ` [f2fs-dev] [PATCH 1/2] f2fs: compress: fix to relocate check condition in f2fs_{release, reserve}_compress_blocks() patchwork-bot+f2fs
  0 siblings, 2 replies; 3+ messages in thread
From: Chao Yu @ 2024-04-07  7:26 UTC (permalink / raw)
  To: jaegeuk; +Cc: Zhiguo Niu, linux-kernel, linux-f2fs-devel

Compress flag should be checked after inode lock held to avoid
racing w/ f2fs_setflags_common(), fix it.

Fixes: 4c8ff7095bef ("f2fs: support data compression")
Reported-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Closes: https://lore.kernel.org/linux-f2fs-devel/CAHJ8P3LdZXLc2rqeYjvymgYHr2+YLuJ0sLG9DdsJZmwO7deuhw@mail.gmail.com
Signed-off-by: Chao Yu <chao@kernel.org>
---
 fs/f2fs/file.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 2cd4ca8433e1..ca401cf8152a 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3549,9 +3549,6 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
 	if (!f2fs_sb_has_compression(sbi))
 		return -EOPNOTSUPP;
 
-	if (!f2fs_compressed_file(inode))
-		return -EINVAL;
-
 	if (f2fs_readonly(sbi->sb))
 		return -EROFS;
 
@@ -3570,7 +3567,8 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
 		goto out;
 	}
 
-	if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
+	if (!f2fs_compressed_file(inode) ||
+		is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
 		ret = -EINVAL;
 		goto out;
 	}
@@ -3731,9 +3729,6 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
 	if (!f2fs_sb_has_compression(sbi))
 		return -EOPNOTSUPP;
 
-	if (!f2fs_compressed_file(inode))
-		return -EINVAL;
-
 	if (f2fs_readonly(sbi->sb))
 		return -EROFS;
 
@@ -3745,7 +3740,8 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg)
 
 	inode_lock(inode);
 
-	if (!is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
+	if (!f2fs_compressed_file(inode) ||
+		!is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
 		ret = -EINVAL;
 		goto unlock_inode;
 	}
-- 
2.40.1



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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [f2fs-dev] [PATCH 2/2] f2fs: compress: fix to relocate check condition in f2fs_ioc_{, de}compress_file()
  2024-04-07  7:26 [f2fs-dev] [PATCH 1/2] f2fs: compress: fix to relocate check condition in f2fs_{release, reserve}_compress_blocks() Chao Yu
@ 2024-04-07  7:26 ` Chao Yu
  2024-04-14 15:32 ` [f2fs-dev] [PATCH 1/2] f2fs: compress: fix to relocate check condition in f2fs_{release, reserve}_compress_blocks() patchwork-bot+f2fs
  1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2024-04-07  7:26 UTC (permalink / raw)
  To: jaegeuk; +Cc: Zhiguo Niu, linux-kernel, linux-f2fs-devel

Compress flag should be checked after inode lock held to avoid
racing w/ f2fs_setflags_common() , fix it.

Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")
Reported-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Closes: https://lore.kernel.org/linux-f2fs-devel/CAHJ8P3LdZXLc2rqeYjvymgYHr2+YLuJ0sLG9DdsJZmwO7deuhw@mail.gmail.com
Signed-off-by: Chao Yu <chao@kernel.org>
---
 fs/f2fs/file.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ca401cf8152a..232dd5fc8ab3 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -4142,9 +4142,6 @@ static int f2fs_ioc_decompress_file(struct file *filp)
 	if (!(filp->f_mode & FMODE_WRITE))
 		return -EBADF;
 
-	if (!f2fs_compressed_file(inode))
-		return -EINVAL;
-
 	f2fs_balance_fs(sbi, true);
 
 	file_start_write(filp);
@@ -4155,7 +4152,8 @@ static int f2fs_ioc_decompress_file(struct file *filp)
 		goto out;
 	}
 
-	if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
+	if (!f2fs_compressed_file(inode) ||
+		is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
 		ret = -EINVAL;
 		goto out;
 	}
@@ -4220,9 +4218,6 @@ static int f2fs_ioc_compress_file(struct file *filp)
 	if (!(filp->f_mode & FMODE_WRITE))
 		return -EBADF;
 
-	if (!f2fs_compressed_file(inode))
-		return -EINVAL;
-
 	f2fs_balance_fs(sbi, true);
 
 	file_start_write(filp);
@@ -4233,7 +4228,8 @@ static int f2fs_ioc_compress_file(struct file *filp)
 		goto out;
 	}
 
-	if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
+	if (!f2fs_compressed_file(inode) ||
+		is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
 		ret = -EINVAL;
 		goto out;
 	}
-- 
2.40.1



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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH 1/2] f2fs: compress: fix to relocate check condition in f2fs_{release, reserve}_compress_blocks()
  2024-04-07  7:26 [f2fs-dev] [PATCH 1/2] f2fs: compress: fix to relocate check condition in f2fs_{release, reserve}_compress_blocks() Chao Yu
  2024-04-07  7:26 ` [f2fs-dev] [PATCH 2/2] f2fs: compress: fix to relocate check condition in f2fs_ioc_{, de}compress_file() Chao Yu
@ 2024-04-14 15:32 ` patchwork-bot+f2fs
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs @ 2024-04-14 15:32 UTC (permalink / raw)
  To: Chao Yu; +Cc: jaegeuk, zhiguo.niu, linux-kernel, linux-f2fs-devel

Hello:

This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Sun,  7 Apr 2024 15:26:03 +0800 you wrote:
> Compress flag should be checked after inode lock held to avoid
> racing w/ f2fs_setflags_common(), fix it.
> 
> Fixes: 4c8ff7095bef ("f2fs: support data compression")
> Reported-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
> Closes: https://lore.kernel.org/linux-f2fs-devel/CAHJ8P3LdZXLc2rqeYjvymgYHr2+YLuJ0sLG9DdsJZmwO7deuhw@mail.gmail.com
> Signed-off-by: Chao Yu <chao@kernel.org>
> 
> [...]

Here is the summary with links:
  - [f2fs-dev,1/2] f2fs: compress: fix to relocate check condition in f2fs_{release, reserve}_compress_blocks()
    https://git.kernel.org/jaegeuk/f2fs/c/7c5dffb3d90c
  - [f2fs-dev,2/2] f2fs: compress: fix to relocate check condition in f2fs_ioc_{, de}compress_file()
    https://git.kernel.org/jaegeuk/f2fs/c/bd9ae4ae9e58

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-14 15:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-07  7:26 [f2fs-dev] [PATCH 1/2] f2fs: compress: fix to relocate check condition in f2fs_{release, reserve}_compress_blocks() Chao Yu
2024-04-07  7:26 ` [f2fs-dev] [PATCH 2/2] f2fs: compress: fix to relocate check condition in f2fs_ioc_{, de}compress_file() Chao Yu
2024-04-14 15:32 ` [f2fs-dev] [PATCH 1/2] f2fs: compress: fix to relocate check condition in f2fs_{release, reserve}_compress_blocks() patchwork-bot+f2fs

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).