linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hfsplus: Verify inode mode when loading from disk
@ 2025-10-04 13:34 Tetsuo Handa
  2025-10-07 14:22 ` Viacheslav Dubeyko
  0 siblings, 1 reply; 7+ messages in thread
From: Tetsuo Handa @ 2025-10-04 13:34 UTC (permalink / raw)
  To: Viacheslav Dubeyko, John Paul Adrian Glaubitz, Yangtao Li,
	linux-fsdevel

The inode mode loaded from corrupted disk can be invalid. Do like what
commit 0a9e74051313 ("isofs: Verify inode mode when loading from disk")
does.

Reported-by: syzbot <syzbot+895c23f6917da440ed0d@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 fs/hfsplus/inode.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index b51a411ecd23..53f653019904 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -558,9 +558,15 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
 			inode->i_op = &page_symlink_inode_operations;
 			inode_nohighmem(inode);
 			inode->i_mapping->a_ops = &hfsplus_aops;
-		} else {
+		} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
+			   S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
 			init_special_inode(inode, inode->i_mode,
 					   be32_to_cpu(file->permissions.dev));
+		} else {
+			printk(KERN_DEBUG "hfsplus: Invalid file type 0%04o for inode %lu.\n",
+			       inode->i_mode, inode->i_ino);
+			res = -EIO;
+			goto out;
 		}
 		inode_set_atime_to_ts(inode, hfsp_mt2ut(file->access_date));
 		inode_set_mtime_to_ts(inode,
-- 
2.47.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-11-17 22:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-04 13:34 [PATCH] hfsplus: Verify inode mode when loading from disk Tetsuo Handa
2025-10-07 14:22 ` Viacheslav Dubeyko
2025-10-08 11:21   ` Tetsuo Handa
2025-11-14 15:35     ` Tetsuo Handa
2025-11-14 19:29       ` Viacheslav Dubeyko
2025-11-15  9:18         ` [PATCH v2] " Tetsuo Handa
2025-11-17 22:52           ` Viacheslav Dubeyko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).