linux/fs/f2fs
Jann Horn 88ff021e1f f2fs: Require FMODE_WRITE for atomic write ioctls
commit 4f5a100f87 upstream.

The F2FS ioctls for starting and committing atomic writes check for
inode_owner_or_capable(), but this does not give LSMs like SELinux or
Landlock an opportunity to deny the write access - if the caller's FSUID
matches the inode's UID, inode_owner_or_capable() immediately returns true.

There are scenarios where LSMs want to deny a process the ability to write
particular files, even files that the FSUID of the process owns; but this
can currently partially be bypassed using atomic write ioctls in two ways:

 - F2FS_IOC_START_ATOMIC_REPLACE + F2FS_IOC_COMMIT_ATOMIC_WRITE can
   truncate an inode to size 0
 - F2FS_IOC_START_ATOMIC_WRITE + F2FS_IOC_ABORT_ATOMIC_WRITE can revert
   changes another process concurrently made to a file

Fix it by requiring FMODE_WRITE for these operations, just like for
F2FS_IOC_MOVE_RANGE. Since any legitimate caller should only be using these
ioctls when intending to write into the file, that seems unlikely to break
anything.

Fixes: 88b88a6679 ("f2fs: support atomic writes")
Cc: stable@vger.kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2024-10-17 15:11:23 +02:00
..
acl.c vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
acl.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
checkpoint.c f2fs: fix typos in comments 2024-06-16 13:39:36 +02:00
compress.c f2fs: fix typos in comments 2024-06-16 13:39:36 +02:00
data.c f2fs: introduce F2FS_IPU_HONOR_OPU_WRITE ipu policy 2024-10-17 15:11:05 +02:00
debug.c f2fs: use spin_lock to avoid hang 2022-04-08 14:23:58 +02:00
dir.c f2fs: prevent possible int overflow in dir_block_index() 2024-10-17 15:11:14 +02:00
extent_cache.c f2fs: fix typos in comments 2024-06-16 13:39:36 +02:00
f2fs.h f2fs: get rid of online repaire on corrupted directory 2024-10-17 15:11:05 +02:00
file.c f2fs: Require FMODE_WRITE for atomic write ioctls 2024-10-17 15:11:23 +02:00
gc.c f2fs: reduce stack memory cost by using bitfield in struct f2fs_io_info 2024-03-26 18:21:32 -04:00
gc.h f2fs: introduce gc_merge mount option 2021-03-30 18:48:56 -07:00
hash.c f2fs: don't use casefolded comparison for "." and ".." 2022-06-09 10:23:17 +02:00
inline.c f2fs: fix return value of f2fs_convert_inline_inode() 2024-08-19 05:44:49 +02:00
inode.c f2fs: fix to don't dirty inode for readonly filesystem 2024-08-19 05:44:49 +02:00
iostat.c f2fs: fix to avoid potential memory corruption in __update_iostat_latency() 2023-03-11 13:57:26 +01:00
iostat.h f2fs: introduce periodic iostat io latency traces 2021-08-23 10:25:51 -07:00
Kconfig f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
Makefile f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
namei.c f2fs: get rid of online repaire on corrupted directory 2024-10-17 15:11:05 +02:00
node.c f2fs: fix to release node block count in error path of f2fs_new_node_page() 2024-06-16 13:39:39 +02:00
node.h f2fs: swap: support migrating swapfile in aligned write mode 2021-06-23 01:09:35 -07:00
recovery.c f2fs: fix write pointers on zoned device after roll forward 2024-02-23 08:54:46 +01:00
segment.c f2fs: fix to do sanity check in update_sit_entry 2024-09-04 13:23:26 +02:00
segment.h f2fs: introduce F2FS_IPU_HONOR_OPU_WRITE ipu policy 2024-10-17 15:11:05 +02:00
shrinker.c f2fs: avoid race condition for shrinker count 2020-12-03 00:59:26 -08:00
super.c f2fs: avoid potential int overflow in sanity_check_area_boundary() 2024-10-17 15:11:14 +02:00
sysfs.c f2fs: fix iostat lock protection 2023-06-14 11:13:00 +02:00
verity.c fs: f2fs: initialize fsdata in pagecache_write() 2023-03-11 13:57:23 +01:00
xattr.c f2fs: reduce expensive checkpoint trigger frequency 2024-10-17 15:11:04 +02:00
xattr.h f2fs: code cleanup by removing ifdef macro surrounding 2020-05-26 18:56:10 -07:00