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
acl.h
checkpoint.c
compress.c
data.c
debug.c
dir.c f2fs: prevent possible int overflow in dir_block_index() 2024-11-23 23:21:31 +01:00
extent_cache.c
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
hash.c
inline.c
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
Makefile
namei.c
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
recovery.c
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
super.c f2fs: avoid potential int overflow in sanity_check_area_boundary() 2024-11-23 23:21:31 +01:00
sysfs.c
verity.c
xattr.c f2fs: remove unneeded check condition in __f2fs_setxattr() 2024-11-23 23:21:27 +01:00
xattr.h