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 AA8A0219A7A; Fri, 17 Oct 2025 15:26:39 +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=1760714799; cv=none; b=RopvEySNs/qk56s3Erh8W+6fy/u8oLxxdOtihswAnVPjCyyzVnsIV/m/ZpuRFnEFgH2aauYAw5YxRtUHYWlpF6ceoU138vaoaePzbXm7c0CF+sPsWb5gsBw0MWPpVhU274iWlloE//sQ80u2jhWrAdESDbVeuUpZtNXNt6b88kI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760714799; c=relaxed/simple; bh=3SggVsFRTWoeUwNrpk3dydAfc2Oi1zorwmQxAmLmofA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AudAdgj6KElKHXYDNsVMFcLAQBcGoT4JShlJkDC5BACtjVI7q9uFPjXGtLxK18baCSQHDFnmjVCUN/eNDjbhHhedewYU/j4jFV0v1ZtUJxoaI77TAQJKRakDWCXjisOzHz+RU+XjgI4G8ljUsQnjHhE0U84oJ2qR7TE8o57Ip2c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wi8tAOv5; 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="wi8tAOv5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37D0CC4CEE7; Fri, 17 Oct 2025 15:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760714799; bh=3SggVsFRTWoeUwNrpk3dydAfc2Oi1zorwmQxAmLmofA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wi8tAOv5cWCfI3z8Lo6VwnDMtEBabfGo6kwJN3NkCxETruRZYnvruyjAO1BQpYZ+s lJ+4qHi+p98OKMWUwdKARtPU9rLk8FztZAJHecHOsYWQz8tRcuz2LVEQ86l6k2ho/E zeJ2iutc0zq11Zl6poexRfedC5URYgYpD66mrFBs= 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.12 270/277] cramfs: Verify inode mode when loading from disk Date: Fri, 17 Oct 2025 16:54:37 +0200 Message-ID: <20251017145157.018683701@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251017145147.138822285@linuxfoundation.org> References: <20251017145147.138822285@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev 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: 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 b84d1747a0205..e7d192f7ab3b4 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