Skip to content

Commit bc107a6

Browse files
Tetsuo Handaakpm00
authored andcommitted
squashfs: verify inode mode when loading from disk
The inode mode loaded from corrupted disk might by error contain the file type bits. Since the file type bits are set by squashfs_read_inode() using bitwise OR, the file type bits must not be set by squashfs_new_inode() from squashfs_read_inode(); otherwise, an invalid file type bits later confuses may_open(). Link: https://lkml.kernel.org/r/[email protected] Reported-by: syzbot <[email protected]> Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d Signed-off-by: Tetsuo Handa <[email protected]> Reviewed-by: Phillip Lougher <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6c0022d commit bc107a6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/squashfs/inode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ static int squashfs_new_inode(struct super_block *sb, struct inode *inode,
6868
inode->i_mode = le16_to_cpu(sqsh_ino->mode);
6969
inode->i_size = 0;
7070

71+
/* File type must not be set at this moment, for it will later be set by the caller. */
72+
if (inode->i_mode & S_IFMT)
73+
err = -EIO;
74+
7175
return err;
7276
}
7377

0 commit comments

Comments
 (0)