From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95CB6296145; Wed, 30 Jul 2025 09:45:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753868733; cv=none; b=Kt5sS4/6xzh4FwYKwMhS9PqYSJjisJdq/RqFmeP5Dl6oyJ8AJOlBW4UT9e/xy5/OHI+uIjHeYQYQFANRGeZOFZpIXLWLJkS8tp8XLHJteG0deJjvIOgimQXToV4gec9ma1nwfxKtFAxxYLZuRcWUyyZ/ieAQwhN7sky6JmZqJ90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753868733; c=relaxed/simple; bh=DZGfaXA0xj29TGW4PMhWlFGH6tszZFZcHNVN360CyEg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WEDlSPYM5NJNSGbU7kLh03aI4RcBdN1qVmCpDhg+p/RG0XnyNK0aVDwgt6KuaLxTOKwU8u0FzAX4/zELA7kW8rTqWWFE9D2xYDoRdfmQo0qWKbJVvUuSY58cmvO5VvEb3Cv/fUC8CU+9XkAuBtj+2OcTtiADodcJVETB1H/YjqQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=W5oKlWTQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="W5oKlWTQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA7DDC4CEF6; Wed, 30 Jul 2025 09:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1753868733; bh=DZGfaXA0xj29TGW4PMhWlFGH6tszZFZcHNVN360CyEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W5oKlWTQ9MkzyCUoWMFCg82bFGfs2t7aDXaHqrLI1F/RpABgLx6lOZtUEklT/WxHU rSgPx24Qbjpc7WtK9BMtW1cyJk3ABbZCFsrApVezxpQzl2PFrUqCbM6XTewXUaBiVu BLSn5QZR1cBOJsPMIE9T2ERY0Hh+IVA7yvaKefbo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ryusuke Konishi , syzbot+895c23f6917da440ed0d@syzkaller.appspotmail.com, Andrew Morton Subject: [PATCH 6.12 061/117] nilfs2: reject invalid file types when reading inodes Date: Wed, 30 Jul 2025 11:35:30 +0200 Message-ID: <20250730093235.925190066@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250730093233.592541778@linuxfoundation.org> References: <20250730093233.592541778@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ryusuke Konishi commit 4aead50caf67e01020c8be1945c3201e8a972a27 upstream. 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 Reported-by: syzbot+895c23f6917da440ed0d@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/inode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -499,11 +499,18 @@ static int __nilfs_read_inode(struct sup inode->i_op = &nilfs_symlink_inode_operations; inode_nohighmem(inode); inode->i_mapping->a_ops = &nilfs_aops; - } else { + } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || + S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { inode->i_op = &nilfs_special_inode_operations; init_special_inode( inode, inode->i_mode, huge_decode_dev(le64_to_cpu(raw_inode->i_device_code))); + } else { + nilfs_error(sb, + "invalid file type bits in mode 0%o for inode %lu", + inode->i_mode, ino); + err = -EIO; + goto failed_unmap; } nilfs_ifile_unmap_inode(raw_inode); brelse(bh);