Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nilfs2: reject invalid file types when reading inodes

To prevent inodes with invalid file types from tripping through the vfs
and causing malfunctions or assertion failures, add a missing sanity check
when reading an inode from a block device. If the file type is not valid,
treat it as a filesystem error.

Link: https://lkml.kernel.org/r/20250710134952.29862-1-konishi.ryusuke@gmail.com
Fixes: 05fe58fdc10d ("nilfs2: inode operations")
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: syzbot+895c23f6917da440ed0d@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Ryusuke Konishi and committed by
Andrew Morton
4aead50c 7563fcbf

+8 -1
+8 -1
fs/nilfs2/inode.c
··· 472 472 inode->i_op = &nilfs_symlink_inode_operations; 473 473 inode_nohighmem(inode); 474 474 inode->i_mapping->a_ops = &nilfs_aops; 475 - } else { 475 + } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || 476 + S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { 476 477 inode->i_op = &nilfs_special_inode_operations; 477 478 init_special_inode( 478 479 inode, inode->i_mode, 479 480 huge_decode_dev(le64_to_cpu(raw_inode->i_device_code))); 481 + } else { 482 + nilfs_error(sb, 483 + "invalid file type bits in mode 0%o for inode %lu", 484 + inode->i_mode, ino); 485 + err = -EIO; 486 + goto failed_unmap; 480 487 } 481 488 nilfs_ifile_unmap_inode(raw_inode); 482 489 brelse(bh);