Skip to content

Commit 5211c67

Browse files
Tetsuo Handagregkh
authored andcommitted
cramfs: Verify inode mode when loading from disk
[ Upstream commit 7f9d34b0a7cb93d678ee7207f0634dbf79e47fe5 ] 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 <[email protected]> Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d Signed-off-by: Tetsuo Handa <[email protected]> Link: https://lore.kernel.org/[email protected] Acked-by: Nicolas Pitre <[email protected]> Signed-off-by: Christian Brauner <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 3b72a03 commit 5211c67

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

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)