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 AC5DA32E147; Fri, 17 Oct 2025 15:13:31 +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=1760714011; cv=none; b=G2px6xZM+KS56lDzprh7XvswTIAi8/yn7Ld/8BbR+WYe4Vo2RC/AuoX8jtDias0qYx4bnNP+vAW+PTm13W5RECKzmCUG/E8cBaQ4l3c5bs0Z17tC50UezCzILUhRYDYx6tPuwu9Pu6VfM/1QIn8oSo74Ov1rsyyUwgiMedQkxfE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760714011; c=relaxed/simple; bh=69XIVgZAi45SwiSqMgY4xzqxYOlDv2XLkd6a7EV8hvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PDztPf67Wgz0HqYKwRQsz2myGwetllzafIEOQVmF/IVFR9nl0FCzmpsEUFLSdKLLGZEo3lZmZIVkk2RRua6yQ+ETPV/gt2y0a+RG4weFwTO+bUVaA+XAbLQuX1i9rp7WPkdOK1mrioICwvyQXtDiW6sbdG2dxBLxG2fx0sU3wus= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=I5bWBv05; 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="I5bWBv05" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2287C4CEE7; Fri, 17 Oct 2025 15:13:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760714011; bh=69XIVgZAi45SwiSqMgY4xzqxYOlDv2XLkd6a7EV8hvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5bWBv05fPfPZmDHytFPQe30uVVu5EpJ6KVGolHfKN6I/yiEb83PvnoStfgmLFwR/ 2wF4bDm0XN5GtshIG4Iy/vtORCnu0HkA910fFM19v+ccH5cgUqgwoGTYxyxBfVw5sJ tWYairWsg3+nkckNg+5WFa3L8GCtMz93jfymCCzE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot , Tetsuo Handa , Nicolas Pitre , Christian Brauner , Sasha Levin Subject: [PATCH 6.6 198/201] cramfs: Verify inode mode when loading from disk Date: Fri, 17 Oct 2025 16:54:19 +0200 Message-ID: <20251017145142.034215423@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251017145134.710337454@linuxfoundation.org> References: <20251017145134.710337454@linuxfoundation.org> User-Agent: quilt/0.69 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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tetsuo Handa [ Upstream commit 7f9d34b0a7cb93d678ee7207f0634dbf79e47fe5 ] The inode mode loaded from corrupted disk can be invalid. Do like what commit 0a9e74051313 ("isofs: Verify inode mode when loading from disk") does. Reported-by: syzbot Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d Signed-off-by: Tetsuo Handa Link: https://lore.kernel.org/429b3ef1-13de-4310-9a8e-c2dc9a36234a@I-love.SAKURA.ne.jp Acked-by: Nicolas Pitre Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/cramfs/inode.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 2fbf97077ce91..3f06362985b5a 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -117,9 +117,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; -- 2.51.0