mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
cramfs: Verify inode mode when loading from disk
The inode mode loaded from corrupted disk can be invalid. Do like what
commit 0a9e740513 ("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>
This commit is contained in:
committed by
Christian Brauner
parent
e5bca063c1
commit
7f9d34b0a7
@@ -116,9 +116,18 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
|
||||
inode_nohighmem(inode);
|
||||
inode->i_data.a_ops = &cramfs_aops;
|
||||
break;
|
||||
default:
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
case S_IFIFO:
|
||||
case S_IFSOCK:
|
||||
init_special_inode(inode, cramfs_inode->mode,
|
||||
old_decode_dev(cramfs_inode->size));
|
||||
break;
|
||||
default:
|
||||
printk(KERN_DEBUG "CRAMFS: Invalid file type 0%04o for inode %lu.\n",
|
||||
inode->i_mode, inode->i_ino);
|
||||
iget_failed(inode);
|
||||
return ERR_PTR(-EIO);
|
||||
}
|
||||
|
||||
inode->i_mode = cramfs_inode->mode;
|
||||
|
||||
Reference in New Issue
Block a user