From nobody Thu Sep 11 11:59:15 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 430CAC636CC for ; Mon, 20 Feb 2023 06:32:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230263AbjBTGc2 (ORCPT ); Mon, 20 Feb 2023 01:32:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjBTGc0 (ORCPT ); Mon, 20 Feb 2023 01:32:26 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59F34EB7C; Sun, 19 Feb 2023 22:32:23 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id DE1851D3F; Mon, 20 Feb 2023 06:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676874488; bh=YtXxZ6e5RLyaBmSaXafOMars1uaos3f4mgep2CPSeUg=; h=Date:To:CC:From:Subject; b=u7g0ARmwjwMj+BrUnDHQHYScdnAKxkHcDoIuM8/l0sq0TGUvtf55cvGSbGxGxkfUl lLN9gyOdwkhB8es6fmxcw+FuoZX1M78QQ3kxLzbl9giqeaXM1ETMq1ZuPSH04UXHJT IkXjgJ8BFbxJDL9dadnp/eADPac2HQMQ64+ZkyUk= Received: from [192.168.211.142] (192.168.211.142) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 20 Feb 2023 09:32:20 +0300 Message-ID: <5de3e85e-3c8e-cc80-c825-481ac9f94f9a@paragon-software.com> Date: Mon, 20 Feb 2023 10:32:20 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: CC: Linux Kernel Mailing List , , Dan Carpenter From: Konstantin Komarov Subject: [PATCH] fs/ntfs3: Fix root inode checking Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.211.142] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Separate checking inode->i_op and inode itself. Reported-by: kernel test robot Reported-by: Dan Carpenter Link: https://lore.kernel.org/r/202302162319.bDJOuyfy-lkp@intel.com/ Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/super.c | 11 ++++++++++- =C2=A01 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index e0f78b306f15..5158dd31fd97 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1347,12 +1347,21 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 ref.low =3D cpu_to_le32(MFT_REC_ROOT); =C2=A0=C2=A0=C2=A0=C2=A0 ref.seq =3D cpu_to_le16(MFT_REC_ROOT); =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_ROOT); -=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode) || !inode->i_op) { +=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load r= oot (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0 /* +=C2=A0=C2=A0=C2=A0 =C2=A0* Final check. Looks like this case should never = occurs. +=C2=A0=C2=A0=C2=A0 =C2=A0*/ +=C2=A0=C2=A0=C2=A0 if (!inode->i_op) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load root (%= d).", err); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_inode_out; +=C2=A0=C2=A0=C2=A0 } + =C2=A0=C2=A0=C2=A0=C2=A0 sb->s_root =3D d_make_root(inode); =C2=A0=C2=A0=C2=A0=C2=A0 if (!sb->s_root) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -ENOMEM; --=20 2.34.1