android_kernel_motorola_sm6375/fs/f2fs
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jann Horn 4ce87674c3 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: [email protected]
Signed-off-by: Jann Horn <[email protected]>
Reviewed-by: Chao Yu <[email protected]>
Reviewed-by: Eric Biggers <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
2024-11-08 16:20:36 +01:00
..
acl.c f2fs: enhance to update i_mode and acl atomically in f2fs_setattr() 2024-11-08 16:20:32 +01:00
acl.h
checkpoint.c f2fs: fix to drop all dirty pages during umount() if cp_error is set 2023-05-30 12:44:03 +01:00
data.c f2fs: fix to drop all dirty pages during umount() if cp_error is set 2023-05-30 12:44:03 +01:00
debug.c
dir.c f2fs: prevent possible int overflow in dir_block_index() 2024-11-08 16:20:34 +01:00
extent_cache.c f2fs: let's avoid panic if extent_tree is not created 2023-01-24 07:17:58 +01:00
f2fs.h f2fs: reduce expensive checkpoint trigger frequency 2024-11-08 16:20:32 +01:00
file.c f2fs: Require FMODE_WRITE for atomic write ioctls 2024-11-08 16:20:36 +01:00
gc.c f2fs: fix to do sanity check on inode type during garbage collection 2023-11-08 11:23:38 +01:00
gc.h
hash.c
inline.c f2fs: use memcpy_{to,from}_page() where possible 2023-03-11 16:44:08 +01:00
inode.c f2fs: fix to don't dirty inode for readonly filesystem 2024-08-19 05:33:37 +02:00
Kconfig
Makefile
namei.c f2fs: fix to avoid dirent corruption 2024-01-25 14:34:27 -08:00
node.c f2fs: fix to release node block count in error path of f2fs_new_node_page() 2024-06-16 13:28:43 +02:00
node.h
recovery.c f2fs: fix to check return value of f2fs_reserve_new_block() 2024-02-23 08:25:00 +01:00
segment.c f2fs: fix to do sanity check in update_sit_entry 2024-09-04 13:14:56 +02:00
segment.h f2fs: fix deadloop in foreground GC 2022-06-14 18:11:44 +02:00
shrinker.c
super.c f2fs: avoid potential int overflow in sanity_check_area_boundary() 2024-11-08 16:20:34 +01:00
sysfs.c
trace.c
trace.h
verity.c fs: f2fs: initialize fsdata in pagecache_write() 2023-03-11 16:44:08 +01:00
xattr.c f2fs: reduce expensive checkpoint trigger frequency 2024-11-08 16:20:32 +01:00
xattr.h