From nobody Tue Sep 16 17:52:14 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 88C9EC4167B for ; Fri, 30 Dec 2022 11:24:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234765AbiL3LYE (ORCPT ); Fri, 30 Dec 2022 06:24:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiL3LYD (ORCPT ); Fri, 30 Dec 2022 06:24:03 -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 0D0D91AD81; Fri, 30 Dec 2022 03:24:02 -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 88B7020EE; Fri, 30 Dec 2022 11:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1672399227; bh=Twpu2s1FblETHbbeLRTjYS0t9CCid29iOzsPHx6E0wE=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=QR5/iro+5wvQnz4zgUWii+eGK6pfLK5jTlP6AP/lb7bu6kBjhnJzTX126KbMljeCh K4C63jAVeRuEkS25Qt480x0jhT43WWldB/Qy8GLP8U46K6BfFoY+Qf8Cvy8OUSLV1S lIK/c64ZDQWH9EXjkXsjMZrSoOuCSTKG1JxPm1ks= Received: from [192.168.211.146] (192.168.211.146) 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; Fri, 30 Dec 2022 14:23:59 +0300 Message-ID: <96b69941-36c3-04a1-cbfb-5a82c11e39f6@paragon-software.com> Date: Fri, 30 Dec 2022 15:23:59 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 1/5] fs/ntfs3: Add null pointer checks Content-Language: en-US From: Konstantin Komarov To: CC: , References: In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.211.146] 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 Added null pointer checks in function ntfs_security_init. Also added le32_to_cpu in functions ntfs_security_init and indx_read. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/fsntfs.c | 16 ++++++++++------ =C2=A0fs/ntfs3/index.c=C2=A0 |=C2=A0 3 ++- =C2=A02 files changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 8de861ddec60..1f36e89dcff7 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -1876,10 +1876,12 @@ int ntfs_security_init(struct ntfs_sb_info *sbi) =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 root_sdh =3D resident_data_ex(attr, sizeof(struct INDEX= _ROOT)); -=C2=A0=C2=A0=C2=A0 if (root_sdh->type !=3D ATTR_ZERO || +=C2=A0=C2=A0=C2=A0 if(!(root_sdh =3D resident_data_ex(attr, sizeof(struct = INDEX_ROOT))) || +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 root_sdh->type !=3D ATTR_ZERO || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 root_sdh->rule !=3D NTFS_COLLA= TION_TYPE_SECURITY_HASH || -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 offsetof(struct INDEX_ROOT, ihdr) + = root_sdh->ihdr.used >=20 attr->res.data_size) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 offsetof(struct INDEX_ROOT, ihdr) + +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 le32_to_cpu(root_= sdh->ihdr.used) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 le32_to_cpu(attr-= >res.data_size)) { =C2=A0=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=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -1895,10 +1897,12 @@ int ntfs_security_init(struct ntfs_sb_info *sbi) =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 root_sii =3D resident_data_ex(attr, sizeof(struct INDEX= _ROOT)); -=C2=A0=C2=A0=C2=A0 if (root_sii->type !=3D ATTR_ZERO || +=C2=A0=C2=A0=C2=A0 if(!(root_sii =3D resident_data_ex(attr, sizeof(struct = INDEX_ROOT))) || +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 root_sii->type !=3D ATTR_ZERO || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 root_sii->rule !=3D NTFS_COLLA= TION_TYPE_UINT || -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 offsetof(struct INDEX_ROOT, ihdr) + = root_sii->ihdr.used >=20 attr->res.data_size) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 offsetof(struct INDEX_ROOT, ihdr) + +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 le32_to_cpu(root_= sii->ihdr.used) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 le32_to_cpu(attr-= >res.data_size)) { =C2=A0=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=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c index f716487ec8a0..8718df791a55 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -1102,7 +1102,8 @@ int indx_read(struct ntfs_index *indx, struct=20 ntfs_inode *ni, CLST vbn, =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 /* check for index header length */ -=C2=A0=C2=A0=C2=A0 if (offsetof(struct INDEX_BUFFER, ihdr) + ib->ihdr.used= > bytes) { +=C2=A0=C2=A0=C2=A0 if (offsetof(struct INDEX_BUFFER, ihdr) + le32_to_cpu(i= b->ihdr.used) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 bytes) { =C2=A0=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=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } --=20 2.34.1 From nobody Tue Sep 16 17:52:14 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 3A795C3DA7C for ; Fri, 30 Dec 2022 11:25:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234781AbiL3LZT (ORCPT ); Fri, 30 Dec 2022 06:25:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234778AbiL3LZR (ORCPT ); Fri, 30 Dec 2022 06:25:17 -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 561321AA3D; Fri, 30 Dec 2022 03:25:16 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id DE17120EE; Fri, 30 Dec 2022 11:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1672399301; bh=IhyjcyPjOgMswqZxmuu5gRIeIvP7uahHFtRFs1brtbo=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=fNkB3w4M7B1DlwImb18fnuXOaqbVJHMipnCdhLUYFgn+lYhn1u2+QANaBcjhGhFJS Yz2kq0eeB9y2QgA4OHtZ9mbheeLjaCNWcBtuFVtZtQ5JwbBnfmt+4fJguDUknaEtYB e+d+u2olbAKUA6sp8HmbTPsBNG+EvlzUEIM7wEbA= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 7FDB6212E; Fri, 30 Dec 2022 11:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1672399514; bh=IhyjcyPjOgMswqZxmuu5gRIeIvP7uahHFtRFs1brtbo=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=S4C/nd8YgpdR/ITjFElMBsYZSVSpv84wYac3uiuoBREKkvJLdGNjN3s7zb9oD/VTg Ra8y9m19ehTPN3b98ttaKxslLDl9FGXotQtl4B8Lk3T06xVge11ByfWTXeJuboUXDA QLWRbM6IcK5kyA2WkOTYtEq/2K0BmVRqHs5jL9AU= Received: from [192.168.211.146] (192.168.211.146) 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; Fri, 30 Dec 2022 14:25:14 +0300 Message-ID: <4e72d357-35de-f0d8-7f4b-f3f0e5f641b8@paragon-software.com> Date: Fri, 30 Dec 2022 15:25:13 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 2/5] fs/ntfs3: Improved checking of attribute's name length Content-Language: en-US From: Konstantin Komarov To: CC: , References: In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.211.146] 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 Added comment, added null pointer checking. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/inode.c | 8 +++++++- =C2=A01 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 8225d0b7c48c..51f9542de7b0 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -137,7 +137,13 @@ static struct inode *ntfs_read_mft(struct inode *inode, =C2=A0=C2=A0=C2=A0=C2=A0 rsize =3D attr->non_res ? 0 : le32_to_cpu(attr->r= es.data_size); =C2=A0=C2=A0=C2=A0=C2=A0 asize =3D le32_to_cpu(attr->size); -=C2=A0=C2=A0=C2=A0 if (le16_to_cpu(attr->name_off) + attr->name_len > asiz= e) +=C2=A0=C2=A0=C2=A0 /* +=C2=A0=C2=A0=C2=A0 =C2=A0* Really this check was done in 'ni_enum_attr_ex'= -> ...=20 'mi_enum_attr'. +=C2=A0=C2=A0=C2=A0 =C2=A0* There not critical to check this case again +=C2=A0=C2=A0=C2=A0 =C2=A0*/ +=C2=A0=C2=A0=C2=A0 if (attr->name_len && +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 sizeof(short) * attr->name_len + le1= 6_to_cpu(attr->name_off) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 asize) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 if (attr->non_res) { --=20 2.34.1 From nobody Tue Sep 16 17:52:14 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 22FC7C4167B for ; Fri, 30 Dec 2022 11:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234813AbiL3LZy (ORCPT ); Fri, 30 Dec 2022 06:25:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234788AbiL3LZv (ORCPT ); Fri, 30 Dec 2022 06:25:51 -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 467BCC6A; Fri, 30 Dec 2022 03:25:51 -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 B4A8220EE; Fri, 30 Dec 2022 11:22:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1672399336; bh=snwY2+VKm0LsKlpAvdxmC463EUj3w2PVok9aOOZl/rI=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=rRz9SCjfJ8B7V/kgmkjToZKbuXssEC25O8lWLZ7lBJJaL4VBHMap3MRnA10pXH3UK FJhG5btOP2lonbcl2n+UtyprUXZcCL7aLFJrezIUIqyieXDKpz0p8jL8ffTZ7yYj3S kyzwnKco+Bqq3u3sx0ASikQ8HsGeHW0Sgl6xfGCI= Received: from [192.168.211.146] (192.168.211.146) 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; Fri, 30 Dec 2022 14:25:48 +0300 Message-ID: <4628ae8a-39e9-ecf8-3efe-193a1ad14d23@paragon-software.com> Date: Fri, 30 Dec 2022 15:25:48 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 3/5] fs/ntfs3: Check for extremely large size of $AttrDef Content-Language: en-US From: Konstantin Komarov To: CC: , References: In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.211.146] 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 Added additional checking for size of $AttrDef. Added comment. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/super.c | 10 +++++++++- =C2=A01 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index ef4ea3f21905..0967035146ce 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1185,10 +1185,18 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =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 if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY)) { +=C2=A0=C2=A0=C2=A0 /* +=C2=A0=C2=A0=C2=A0 =C2=A0* Typical $AttrDef contains up to 20 entries. +=C2=A0=C2=A0=C2=A0 =C2=A0* Check for extremely large size. +=C2=A0=C2=A0=C2=A0 =C2=A0*/ +=C2=A0=C2=A0=C2=A0 if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY) || +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 inode->i_size > 100 * sizeof(struct = ATTR_DEF_ENTRY)) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Looks like $AttrDef is= corrupted (size=3D%llu).", +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_si= ze); =C2=A0=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=C2=A0 goto put_inode_out; =C2=A0=C2=A0=C2=A0=C2=A0 } + =C2=A0=C2=A0=C2=A0=C2=A0 bytes =3D inode->i_size; =C2=A0=C2=A0=C2=A0=C2=A0 sbi->def_table =3D t =3D kmalloc(bytes, GFP_NOFS = | __GFP_NOWARN); =C2=A0=C2=A0=C2=A0=C2=A0 if (!t) { --=20 2.34.1 From nobody Tue Sep 16 17:52:14 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 3B7F8C4167B for ; Fri, 30 Dec 2022 11:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234855AbiL3L0Z (ORCPT ); Fri, 30 Dec 2022 06:26:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234788AbiL3L0X (ORCPT ); Fri, 30 Dec 2022 06:26:23 -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 655D7140C0; Fri, 30 Dec 2022 03:26:22 -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 D9A0A20EE; Fri, 30 Dec 2022 11:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1672399367; bh=cx5DEN5yzbTg0lbldjz4Ma6Es6+57SY1O3L9oJVV9ds=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=rOEzMTST7ax17Nj+YLDvGarYh5kQ4KDBZeIOEVQIFf9UdpJRgksIAO8OzHWe07Y8g NK9ZUKG7fjgENsYOtlTdC1K3nh19owa7PFtoNKc4hD34JSAhzEsDbvu1hJa0OAv6dX +ZqmdLtXwNJcFp5/AxN6k/uEs5yqWbUzbyL4n7Gs= Received: from [192.168.211.146] (192.168.211.146) 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; Fri, 30 Dec 2022 14:26:19 +0300 Message-ID: Date: Fri, 30 Dec 2022 15:26:18 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 4/5] fs/ntfs3: Restore overflow checking for attr size in mi_enum_attr Content-Language: en-US From: Konstantin Komarov To: CC: , References: In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.211.146] 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 Fixed comment. Removed explicit initialization for INDEX_ROOT. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/index.c=C2=A0 | 7 ++++--- =C2=A0fs/ntfs3/record.c | 5 +++++ =C2=A0fs/ntfs3/super.c=C2=A0 | 2 +- =C2=A03 files changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c index 8718df791a55..9fefeac5fe7e 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -994,7 +994,7 @@ struct INDEX_ROOT *indx_get_root(struct ntfs_index=20 *indx, struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0=C2=A0 struct ATTR_LIST_ENTRY *le =3D NULL; =C2=A0=C2=A0=C2=A0=C2=A0 struct ATTRIB *a; =C2=A0=C2=A0=C2=A0=C2=A0 const struct INDEX_NAMES *in =3D &s_index_names[i= ndx->type]; -=C2=A0=C2=A0=C2=A0 struct INDEX_ROOT *root =3D NULL; +=C2=A0=C2=A0=C2=A0 struct INDEX_ROOT *root; =C2=A0=C2=A0=C2=A0=C2=A0 a =3D ni_find_attr(ni, NULL, &le, ATTR_ROOT, in->= name, in->name_len,=20 NULL, =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mi); @@ -1007,8 +1007,9 @@ struct INDEX_ROOT *indx_get_root(struct ntfs_index=20 *indx, struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0=C2=A0 root =3D resident_data_ex(a, sizeof(struct INDEX_= ROOT)); =C2=A0=C2=A0=C2=A0=C2=A0 /* length check */ -=C2=A0=C2=A0=C2=A0 if (root && offsetof(struct INDEX_ROOT, ihdr) +=20 le32_to_cpu(root->ihdr.used) > -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 le32_to_cpu(a->re= s.data_size)) { +=C2=A0=C2=A0=C2=A0 if (root && +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 offsetof(struct INDEX_ROOT, ihdr) + = le32_to_cpu(root->ihdr.used) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 le32_to_cpu(a->re= s.data_size)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return NULL; =C2=A0=C2=A0=C2=A0=C2=A0 } diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index abfe004774c0..0603169ee8a0 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -220,6 +220,11 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi,=20 struct ATTRIB *attr) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return NULL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (off + asize < off) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* Overflow check= . */ +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return NULL; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } + =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 attr =3D Add2Ptr(attr, asize); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 off +=3D asize; =C2=A0=C2=A0=C2=A0=C2=A0 } diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 0967035146ce..19d0889b131f 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1187,7 +1187,7 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 /* =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0* Typical $AttrDef contains up to 20 entrie= s. -=C2=A0=C2=A0=C2=A0 =C2=A0* Check for extremely large size. +=C2=A0=C2=A0=C2=A0 =C2=A0* Check for extremely large/small size. =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0*/ =C2=A0=C2=A0=C2=A0=C2=A0 if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY)= || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 inode->i_size > 100 * sizeof(s= truct ATTR_DEF_ENTRY)) { --=20 2.34.1 From nobody Tue Sep 16 17:52:14 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 81864C4167B for ; Fri, 30 Dec 2022 11:27:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234905AbiL3L1I (ORCPT ); Fri, 30 Dec 2022 06:27:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234884AbiL3L1F (ORCPT ); Fri, 30 Dec 2022 06:27:05 -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 61D8E140C0; Fri, 30 Dec 2022 03:27:04 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id DF32E20EE; Fri, 30 Dec 2022 11:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1672399410; bh=ETfFUvoUKgLpON3I17vb6pr52MbHQUStImHG554hLLg=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=m3uMIOY07QexW/QEC03Gg3hzd1eiQr6WHOX28Wlpvv/DQ0welfS7ZlvIn0FA2yTeG 8c9BvZsLlZ5lPi2kQjLtpmMa11MfEveTuX3HM0dkq34E4C7o3rDCsh9z6LNRNXfPtJ pJAeW6hfWuFrWihLbj6dvwoD5diqRIXlT+f9e8zM= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 770FF212E; Fri, 30 Dec 2022 11:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1672399622; bh=ETfFUvoUKgLpON3I17vb6pr52MbHQUStImHG554hLLg=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=d+FBdD87msNX675SNfkxg1MWCFE8S9NyJJzohNw8KyCFe/YydT3wivc9wFNptdAyF u0H0UVDLkLjZET1sRa/MM6EdA2Cm3xCLSy/V/X1sMGSnAY1Trb4nObxTfAKxLFclzI BqV+/25izhjLXiOsOuTmLC1FmROtJNErsi/ZS5ZY= Received: from [192.168.211.146] (192.168.211.146) 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; Fri, 30 Dec 2022 14:27:01 +0300 Message-ID: Date: Fri, 30 Dec 2022 15:27:01 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: [PATCH 5/5] fs/ntfs3: Refactoring of various minor issues Content-Language: en-US From: Konstantin Komarov To: CC: , References: In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.211.146] 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 Removed unused macro. Changed null pointer checking. Fixed inconsistent indenting. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/bitmap.c=C2=A0 | 3 ++- =C2=A0fs/ntfs3/frecord.c | 2 +- =C2=A0fs/ntfs3/fsntfs.c=C2=A0 | 6 ++++-- =C2=A0fs/ntfs3/namei.c=C2=A0=C2=A0 | 2 +- =C2=A0fs/ntfs3/ntfs.h=C2=A0=C2=A0=C2=A0 | 3 --- =C2=A05 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c index 723fb64e6531..393c726ef17a 100644 --- a/fs/ntfs3/bitmap.c +++ b/fs/ntfs3/bitmap.c @@ -658,7 +658,8 @@ int wnd_init(struct wnd_bitmap *wnd, struct=20 super_block *sb, size_t nbits) =C2=A0=C2=A0=C2=A0 =C2=A0if (!wnd->bits_last) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0wnd->bits_last =3D wbits; -=C2=A0=C2=A0 =C2=A0wnd->free_bits =3D kcalloc(wnd->nwnd, sizeof(u16), GFP_= NOFS |=20 __GFP_NOWARN); +=C2=A0=C2=A0 =C2=A0wnd->free_bits =3D +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kcalloc(wnd->nwnd, sizeof(u16), GFP_= NOFS | __GFP_NOWARN); =C2=A0=C2=A0=C2=A0 =C2=A0if (!wnd->free_bits) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOMEM; diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 912eeb3d3471..1103d4d9a497 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -1645,7 +1645,7 @@ struct ATTR_FILE_NAME *ni_fname_name(struct=20 ntfs_inode *ni, =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTR_FILE_NAME *fname; -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct le_str *fns; +=C2=A0=C2=A0 =C2=A0struct le_str *fns; =C2=A0=C2=A0=C2=A0 =C2=A0if (le) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0*le =3D NULL; diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 1f36e89dcff7..342938704cfd 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -2599,8 +2599,10 @@ static inline bool is_reserved_name(struct=20 ntfs_sb_info *sbi, =C2=A0=C2=A0=C2=A0 =C2=A0if (len =3D=3D 4 || (len > 4 && le16_to_cpu(name[= 4]) =3D=3D '.')) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0port_digit =3D le16_to_cpu(nam= e[3]); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (port_digit >=3D '1' && por= t_digit <=3D '9') -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!ntfs_cmp_nam= es(name, 3, COM_NAME, 3, upcase, false) || -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 !ntfs_cmp_names(name, 3, LPT_NAME, 3, upcase, false)) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!ntfs_cmp_nam= es(name, 3, COM_NAME, 3, upcase, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 false) || +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 !ntfs_cmp_names(name, 3, LPT_NAME, 3, upcase, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 false)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0return true; =C2=A0=C2=A0=C2=A0 =C2=A0} diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index 3db34d5c03dc..53ddea219e37 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -93,7 +93,7 @@ static struct dentry *ntfs_lookup(struct inode *dir,=20 struct dentry *dentry, =C2=A0=C2=A0=C2=A0 =C2=A0 * If the MFT record of ntfs inode is not a base = record,=20 inode->i_op can be NULL. =C2=A0=C2=A0=C2=A0 =C2=A0 * This causes null pointer dereference in d_spli= ce_alias(). =C2=A0=C2=A0=C2=A0 =C2=A0 */ -=C2=A0=C2=A0 =C2=A0if (!IS_ERR(inode) && inode->i_op =3D=3D NULL) { +=C2=A0=C2=A0 =C2=A0if (!IS_ERR_OR_NULL(inode) && !inode->i_op) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0iput(inode); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode =3D ERR_PTR(-EINVAL); =C2=A0=C2=A0=C2=A0 =C2=A0} diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index 86ea1826d099..90151e56c122 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -435,9 +435,6 @@ static inline u64 attr_svcn(const struct ATTRIB *attr) =C2=A0=C2=A0=C2=A0 =C2=A0return attr->non_res ? le64_to_cpu(attr->nres.svc= n) : 0; =C2=A0} -/* The size of resident attribute by its resident size. */ -#define BYTES_PER_RESIDENT(b) (0x18 + (b)) - =C2=A0static_assert(sizeof(struct ATTRIB) =3D=3D 0x48); =C2=A0static_assert(sizeof(((struct ATTRIB *)NULL)->res) =3D=3D 0x08); =C2=A0static_assert(sizeof(((struct ATTRIB *)NULL)->nres) =3D=3D 0x38); --=20 2.34.1