android_kernel_xiaomi_sm8450/fs/f2fs
Jann Horn 000bab8753 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: 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>
2024-10-17 15:08:09 +02:00
..
acl.c f2fs: enhance to update i_mode and acl atomically in f2fs_setattr() 2024-10-17 15:07:55 +02:00
acl.h f2fs: Use the correct style for SPDX License Identifier 2020-05-08 06:55:55 -07:00
checkpoint.c f2fs: fix typos in comments 2024-06-16 13:32:18 +02:00
compress.c f2fs: compress: fix compression chksum 2024-06-16 13:32:36 +02:00
data.c f2fs: fix typos in comments 2024-06-16 13:32:18 +02:00
debug.c f2fs: avoid race condition for shrinker count 2021-01-06 14:56:54 +01:00
dir.c f2fs: prevent possible int overflow in dir_block_index() 2024-10-17 15:08:02 +02:00
extent_cache.c f2fs: fix typos in comments 2024-06-16 13:32:18 +02:00
f2fs.h f2fs: reduce expensive checkpoint trigger frequency 2024-10-17 15:07:56 +02:00
file.c f2fs: Require FMODE_WRITE for atomic write ioctls 2024-10-17 15:08:09 +02:00
gc.c f2fs: fix to do sanity check on inode type during garbage collection 2023-11-08 17:30:46 +01:00
gc.h f2fs: support age threshold based garbage collection 2020-09-11 11:11:15 -07:00
hash.c f2fs-for-5.8-rc1 2020-06-09 11:28:59 -07:00
inline.c f2fs: use memcpy_{to,from}_page() where possible 2023-03-11 16:40:09 +01:00
inode.c f2fs: fix to don't dirty inode for readonly filesystem 2024-08-19 05:40:59 +02:00
Kconfig f2fs: compress: support lzo-rle compress algorithm 2020-05-11 20:36:46 -07:00
Makefile f2fs: support data compression 2020-01-17 16:48:07 -08:00
namei.c f2fs: fix typos in comments 2024-06-16 13:32:18 +02:00
node.c f2fs: fix to release node block count in error path of f2fs_new_node_page() 2024-06-16 13:32:21 +02:00
node.h f2fs: avoid race condition for shrinker count 2021-01-06 14:56:54 +01:00
recovery.c f2fs: fix write pointers on zoned device after roll forward 2024-02-23 08:42:11 +01:00
segment.c f2fs: fix to do sanity check in update_sit_entry 2024-09-04 13:17:37 +02:00
segment.h f2fs: fix start segno of large section 2024-08-19 05:41:03 +02:00
shrinker.c f2fs: avoid race condition for shrinker count 2021-01-06 14:56:54 +01:00
super.c f2fs: avoid potential int overflow in sanity_check_area_boundary() 2024-10-17 15:08:02 +02:00
sysfs.c f2fs: fix iostat lock protection 2023-06-14 11:09:31 +02:00
trace.c f2fs: do not use mutex lock in atomic context 2019-03-05 19:58:06 -08:00
trace.h f2fs: Use the correct style for SPDX License Identifier 2020-05-08 06:55:55 -07:00
verity.c fs: f2fs: initialize fsdata in pagecache_write() 2023-03-11 16:40:09 +01:00
xattr.c f2fs: reduce expensive checkpoint trigger frequency 2024-10-17 15:07:56 +02:00
xattr.h f2fs: code cleanup by removing ifdef macro surrounding 2020-05-26 18:56:10 -07:00