kernel_samsung_a53x/fs/f2fs
Jann Horn 3877a33618 f2fs: Require FMODE_WRITE for atomic write ioctls
commit 4f5a100f87f32cb65d4bb1ad282a08c92f6f591e 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: 88b88a667971 ("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>
2024-11-23 23:21:37 +01:00
..
acl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
acl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
checkpoint.c f2fs: use copy_page for full page copy 2024-11-17 17:41:42 +01:00
compress.c f2fs: compress: remove unneeded preallocation 2024-11-19 12:27:02 +01:00
data.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debug.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dir.c f2fs: prevent possible int overflow in dir_block_index() 2024-11-23 23:21:31 +01:00
extent_cache.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
f2fs.h f2fs: fix typo 2024-11-23 23:21:26 +01:00
file.c f2fs: Require FMODE_WRITE for atomic write ioctls 2024-11-23 23:21:37 +01:00
gc.c f2fs: set ioprio of GC kthread to idle 2024-11-19 17:55:41 +01:00
gc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hash.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inline.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inode.c f2fs: fix to do sanity check on i_xattr_nid in sanity_check_inode() 2024-11-19 12:27:13 +01:00
Kconfig f2fs: Add support for reporting a fake kernel version to fsck 2024-11-17 17:43:26 +01:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
namei.c f2fs: fix to avoid dirent corruption 2024-11-18 12:12:39 +01:00
node.c f2fs: fix to release node block count in error path of f2fs_new_node_page() 2024-11-19 12:27:05 +01:00
node.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
recovery.c f2fs: fix write pointers on zoned device after roll forward 2024-11-18 12:13:17 +01:00
segment.c f2fs: fix to do sanity check in update_sit_entry 2024-11-23 23:20:46 +01:00
segment.h f2fs: fix start segno of large section 2024-11-23 23:20:16 +01:00
shrinker.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
super.c f2fs: avoid potential int overflow in sanity_check_area_boundary() 2024-11-23 23:21:31 +01:00
sysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
verity.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xattr.c f2fs: remove unneeded check condition in __f2fs_setxattr() 2024-11-23 23:21:27 +01:00
xattr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00