Commit bd9ae4ae authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: compress: fix to relocate check condition in f2fs_ioc_{,de}compress_file()

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

Fixes: 5fdb322f ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")
Reported-by: default avatarZhiguo Niu <zhiguo.niu@unisoc.com>
Closes: https://lore.kernel.org/linux-f2fs-devel/CAHJ8P3LdZXLc2rqeYjvymgYHr2+YLuJ0sLG9DdsJZmwO7deuhw@mail.gmail.comSigned-off-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 7c5dffb3
...@@ -4136,9 +4136,6 @@ static int f2fs_ioc_decompress_file(struct file *filp) ...@@ -4136,9 +4136,6 @@ static int f2fs_ioc_decompress_file(struct file *filp)
if (!(filp->f_mode & FMODE_WRITE)) if (!(filp->f_mode & FMODE_WRITE))
return -EBADF; return -EBADF;
if (!f2fs_compressed_file(inode))
return -EINVAL;
f2fs_balance_fs(sbi, true); f2fs_balance_fs(sbi, true);
file_start_write(filp); file_start_write(filp);
...@@ -4149,7 +4146,8 @@ static int f2fs_ioc_decompress_file(struct file *filp) ...@@ -4149,7 +4146,8 @@ static int f2fs_ioc_decompress_file(struct file *filp)
goto out; 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; ret = -EINVAL;
goto out; goto out;
} }
...@@ -4214,9 +4212,6 @@ static int f2fs_ioc_compress_file(struct file *filp) ...@@ -4214,9 +4212,6 @@ static int f2fs_ioc_compress_file(struct file *filp)
if (!(filp->f_mode & FMODE_WRITE)) if (!(filp->f_mode & FMODE_WRITE))
return -EBADF; return -EBADF;
if (!f2fs_compressed_file(inode))
return -EINVAL;
f2fs_balance_fs(sbi, true); f2fs_balance_fs(sbi, true);
file_start_write(filp); file_start_write(filp);
...@@ -4227,7 +4222,8 @@ static int f2fs_ioc_compress_file(struct file *filp) ...@@ -4227,7 +4222,8 @@ static int f2fs_ioc_compress_file(struct file *filp)
goto out; 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; ret = -EINVAL;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment