linux/fs/hfsplus
Tetsuo Handa 005d4b0d33 hfsplus: Verify inode mode when loading from disk
syzbot is reporting that S_IFMT bits of inode->i_mode can become bogus when
the S_IFMT bits of the 16bits "mode" field loaded from disk are corrupted.

According to [1], the permissions field was treated as reserved in Mac OS
8 and 9. According to [2], the reserved field was explicitly initialized
with 0, and that field must remain 0 as long as reserved. Therefore, when
the "mode" field is not 0 (i.e. no longer reserved), the file must be
S_IFDIR if dir == 1, and the file must be one of S_IFREG/S_IFLNK/S_IFCHR/
S_IFBLK/S_IFIFO/S_IFSOCK if dir == 0.

Reported-by: syzbot <syzbot+895c23f6917da440ed0d@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d
Link: https://developer.apple.com/library/archive/technotes/tn/tn1150.html#HFSPlusPermissions [1]
Link: https://developer.apple.com/library/archive/technotes/tn/tn1150.html#ReservedAndPadFields [2]
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
Link: https://lore.kernel.org/r/04ded9f9-73fb-496c-bfa5-89c4f5d1d7bb@I-love.SAKURA.ne.jp
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
2025-11-18 16:01:05 -08:00
..
attributes.c hfs/hfsplus: rework debug output subsystem 2025-09-24 16:30:34 -07:00
bfind.c hfs/hfsplus: prevent getting negative values of offset/length 2025-11-13 15:02:52 -08:00
bitmap.c hfs/hfsplus: rework debug output subsystem 2025-09-24 16:30:34 -07:00
bnode.c hfsplus: fix volume corruption issue for generic/070 2025-11-13 15:04:52 -08:00
brec.c hfs/hfsplus: prevent getting negative values of offset/length 2025-11-13 15:02:52 -08:00
btree.c hfs/hfsplus: prevent getting negative values of offset/length 2025-11-13 15:02:52 -08:00
catalog.c hfs/hfsplus: rework debug output subsystem 2025-09-24 16:30:34 -07:00
dir.c hfsplus: fix slab-out-of-bounds read in hfsplus_uni2asc() 2025-09-09 11:44:38 -07:00
extents.c hfs/hfsplus: rework debug output subsystem 2025-09-24 16:30:34 -07:00
hfsplus_fs.h hfs/hfsplus: prevent getting negative values of offset/length 2025-11-13 15:02:52 -08:00
hfsplus_raw.h hfsplus: use struct_group_attr() for memcpy() region 2022-01-20 08:52:54 +02:00
inode.c hfsplus: Verify inode mode when loading from disk 2025-11-18 16:01:05 -08:00
ioctl.c vfs: rename parent_ino to d_parent_ino and make it use RCU 2024-06-27 18:34:21 +02:00
Kconfig fs: add CONFIG_BUFFER_HEAD 2023-08-02 09:13:09 -06:00
Makefile hfsplus: drop ACL support 2018-08-22 10:52:50 -07:00
options.c hfsplus: convert hfsplus to use the new mount api 2024-10-08 14:41:50 +02:00
part_tbl.c fs/hfsplus: Use the enum req_op and blk_opf_t types 2022-07-14 12:14:32 -06:00
super.c hfs/hfsplus: rework debug output subsystem 2025-09-24 16:30:34 -07:00
tables.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
unicode.c hfsplus: fix slab-out-of-bounds read in hfsplus_strcasecmp() 2025-09-22 15:11:33 -07:00
wrapper.c hfsplus: use bdev_rw_virt in hfsplus_submit_bio 2025-05-07 07:31:08 -06:00
xattr.c hfs/hfsplus: rework debug output subsystem 2025-09-24 16:30:34 -07:00
xattr.h hfsplus: move hfsplus_xattr_handlers to .rodata 2023-10-09 16:24:19 +02:00
xattr_security.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00
xattr_trusted.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00
xattr_user.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00