Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit d6f08c8

Browse files
chaseyugregkh
authored andcommittedOct 4, 2024
f2fs: fix to check atomic_file in f2fs ioctl interfaces
commit bfe5c02 upstream. 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: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d2352b5 commit d6f08c8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
 

‎fs/f2fs/file.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -2716,7 +2716,8 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
27162716
(range->start + range->len) >> PAGE_SHIFT,
27172717
DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE));
27182718

2719-
if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
2719+
if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) ||
2720+
f2fs_is_atomic_file(inode)) {
27202721
err = -EINVAL;
27212722
goto unlock_out;
27222723
}
@@ -2949,6 +2950,11 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
29492950
goto out_unlock;
29502951
}
29512952

2953+
if (f2fs_is_atomic_file(src) || f2fs_is_atomic_file(dst)) {
2954+
ret = -EINVAL;
2955+
goto out_unlock;
2956+
}
2957+
29522958
ret = -EINVAL;
29532959
if (pos_in + len > src->i_size || pos_in + len < pos_in)
29542960
goto out_unlock;
@@ -3332,6 +3338,11 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg)
33323338

33333339
inode_lock(inode);
33343340

3341+
if (f2fs_is_atomic_file(inode)) {
3342+
ret = -EINVAL;
3343+
goto out;
3344+
}
3345+
33353346
if (!pin) {
33363347
clear_inode_flag(inode, FI_PIN_FILE);
33373348
f2fs_i_gc_failures_write(inode, 0);

0 commit comments

Comments
 (0)
This repository has been archived.