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

f2fs: fix to check atomic_file in f2fs ioctl interfaces

Some f2fs ioctl interfaces like f2fs_ioc_set_pin_file(),
f2fs_move_file_range(), and f2fs_defragment_range() missed to
check atomic_write status, which may cause potential race issue,
fix it.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 884ee6dc
...@@ -2710,7 +2710,8 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, ...@@ -2710,7 +2710,8 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
(range->start + range->len) >> PAGE_SHIFT, (range->start + range->len) >> PAGE_SHIFT,
DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE)); DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE));
if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) { if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) ||
f2fs_is_atomic_file(inode)) {
err = -EINVAL; err = -EINVAL;
goto unlock_out; goto unlock_out;
} }
...@@ -2943,6 +2944,11 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, ...@@ -2943,6 +2944,11 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
goto out_unlock; goto out_unlock;
} }
if (f2fs_is_atomic_file(src) || f2fs_is_atomic_file(dst)) {
ret = -EINVAL;
goto out_unlock;
}
ret = -EINVAL; ret = -EINVAL;
if (pos_in + len > src->i_size || pos_in + len < pos_in) if (pos_in + len > src->i_size || pos_in + len < pos_in)
goto out_unlock; goto out_unlock;
...@@ -3326,6 +3332,11 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg) ...@@ -3326,6 +3332,11 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg)
inode_lock(inode); inode_lock(inode);
if (f2fs_is_atomic_file(inode)) {
ret = -EINVAL;
goto out;
}
if (!pin) { if (!pin) {
clear_inode_flag(inode, FI_PIN_FILE); clear_inode_flag(inode, FI_PIN_FILE);
f2fs_i_gc_failures_write(inode, 0); f2fs_i_gc_failures_write(inode, 0);
......
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