Skip to content

Commit 7f9d34b

Browse files
Tetsuo Handabrauner
authored andcommitted
cramfs: Verify inode mode when loading from disk
The inode mode loaded from corrupted disk can be invalid. Do like what commit 0a9e740 ("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> Link: https://lore.kernel.org/429b3ef1-13de-4310-9a8e-c2dc9a36234a@I-love.SAKURA.ne.jp Acked-by: Nicolas Pitre <nico@fluxnic.net> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent e5bca06 commit 7f9d34b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

fs/cramfs/inode.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,18 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
116116
inode_nohighmem(inode);
117117
inode->i_data.a_ops = &cramfs_aops;
118118
break;
119-
default:
119+
case S_IFCHR:
120+
case S_IFBLK:
121+
case S_IFIFO:
122+
case S_IFSOCK:
120123
init_special_inode(inode, cramfs_inode->mode,
121124
old_decode_dev(cramfs_inode->size));
125+
break;
126+
default:
127+
printk(KERN_DEBUG "CRAMFS: Invalid file type 0%04o for inode %lu.\n",
128+
inode->i_mode, inode->i_ino);
129+
iget_failed(inode);
130+
return ERR_PTR(-EIO);
122131
}
123132

124133
inode->i_mode = cramfs_inode->mode;

0 commit comments

Comments
 (0)