Skip to content

Commit bfe5c02

Browse files
chaseyuJaegeuk Kim
authored andcommitted
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: [email protected] Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 884ee6d commit bfe5c02

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

fs/f2fs/file.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2710,7 +2710,8 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
27102710
(range->start + range->len) >> PAGE_SHIFT,
27112711
DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE));
27122712

2713-
if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
2713+
if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) ||
2714+
f2fs_is_atomic_file(inode)) {
27142715
err = -EINVAL;
27152716
goto unlock_out;
27162717
}
@@ -2943,6 +2944,11 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
29432944
goto out_unlock;
29442945
}
29452946

2947+
if (f2fs_is_atomic_file(src) || f2fs_is_atomic_file(dst)) {
2948+
ret = -EINVAL;
2949+
goto out_unlock;
2950+
}
2951+
29462952
ret = -EINVAL;
29472953
if (pos_in + len > src->i_size || pos_in + len < pos_in)
29482954
goto out_unlock;
@@ -3326,6 +3332,11 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg)
33263332

33273333
inode_lock(inode);
33283334

3335+
if (f2fs_is_atomic_file(inode)) {
3336+
ret = -EINVAL;
3337+
goto out;
3338+
}
3339+
33293340
if (!pin) {
33303341
clear_inode_flag(inode, FI_PIN_FILE);
33313342
f2fs_i_gc_failures_write(inode, 0);

0 commit comments

Comments
 (0)