From patchwork Fri Dec 30 11:23:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 13084260 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 0E55CC4167B for ; Fri, 30 Dec 2022 11:24:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234680AbiL3LYE (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: 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-fsdevel@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 ---  fs/ntfs3/fsntfs.c | 16 ++++++++++------  fs/ntfs3/index.c  |  3 ++-  2 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)          goto out;      } -    root_sdh = resident_data_ex(attr, sizeof(struct INDEX_ROOT)); -    if (root_sdh->type != ATTR_ZERO || +    if(!(root_sdh = resident_data_ex(attr, sizeof(struct INDEX_ROOT))) || +        root_sdh->type != ATTR_ZERO ||          root_sdh->rule != NTFS_COLLATION_TYPE_SECURITY_HASH || -        offsetof(struct INDEX_ROOT, ihdr) + root_sdh->ihdr.used > attr->res.data_size) { +        offsetof(struct INDEX_ROOT, ihdr) + +            le32_to_cpu(root_sdh->ihdr.used) > +            le32_to_cpu(attr->res.data_size)) {          err = -EINVAL;          goto out;      } @@ -1895,10 +1897,12 @@ int ntfs_security_init(struct ntfs_sb_info *sbi)          goto out;      } -    root_sii = resident_data_ex(attr, sizeof(struct INDEX_ROOT)); -    if (root_sii->type != ATTR_ZERO || +    if(!(root_sii = resident_data_ex(attr, sizeof(struct INDEX_ROOT))) || +        root_sii->type != ATTR_ZERO ||          root_sii->rule != NTFS_COLLATION_TYPE_UINT || -        offsetof(struct INDEX_ROOT, ihdr) + root_sii->ihdr.used > attr->res.data_size) { +        offsetof(struct INDEX_ROOT, ihdr) + +            le32_to_cpu(root_sii->ihdr.used) > +            le32_to_cpu(attr->res.data_size)) {          err = -EINVAL;          goto out;      } 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 ntfs_inode *ni, CLST vbn,      }      /* check for index header length */ -    if (offsetof(struct INDEX_BUFFER, ihdr) + ib->ihdr.used > bytes) { +    if (offsetof(struct INDEX_BUFFER, ihdr) + le32_to_cpu(ib->ihdr.used) > +        bytes) {          err = -EINVAL;          goto out; From patchwork Fri Dec 30 11:25:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 13084261 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 E5568C4167B for ; Fri, 30 Dec 2022 11:25:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230087AbiL3LZS (ORCPT ); Fri, 30 Dec 2022 06:25:18 -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: 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-fsdevel@vger.kernel.org Added comment, added null pointer checking. Signed-off-by: Konstantin Komarov ---  fs/ntfs3/inode.c | 8 +++++++-  1 file changed, 7 insertions(+), 1 deletion(-)      if (attr->non_res) { 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,      rsize = attr->non_res ? 0 : le32_to_cpu(attr->res.data_size);      asize = le32_to_cpu(attr->size); -    if (le16_to_cpu(attr->name_off) + attr->name_len > asize) +    /* +     * Really this check was done in 'ni_enum_attr_ex' -> ... 'mi_enum_attr'. +     * There not critical to check this case again +     */ +    if (attr->name_len && +        sizeof(short) * attr->name_len + le16_to_cpu(attr->name_off) > +            asize)          goto out; From patchwork Fri Dec 30 11:25:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 13084262 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 C47F4C4167B for ; Fri, 30 Dec 2022 11:25:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234797AbiL3LZw (ORCPT ); Fri, 30 Dec 2022 06:25:52 -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: 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-fsdevel@vger.kernel.org Added additional checking for size of $AttrDef. Added comment. Signed-off-by: Konstantin Komarov ---  fs/ntfs3/super.c | 10 +++++++++-  1 file changed, 9 insertions(+), 1 deletion(-)      if (!t) { 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 *sb, struct fs_context *fc)          goto out;      } -    if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY)) { +    /* +     * Typical $AttrDef contains up to 20 entries. +     * Check for extremely large size. +     */ +    if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY) || +        inode->i_size > 100 * sizeof(struct ATTR_DEF_ENTRY)) { +        ntfs_err(sb, "Looks like $AttrDef is corrupted (size=%llu).", +             inode->i_size);          err = -EINVAL;          goto put_inode_out;      } +      bytes = inode->i_size;      sbi->def_table = t = kmalloc(bytes, GFP_NOFS | __GFP_NOWARN); From patchwork Fri Dec 30 11:26:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 13084271 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 B8111C4167B for ; Fri, 30 Dec 2022 11:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234824AbiL3L0Y (ORCPT ); Fri, 30 Dec 2022 06:26:24 -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: 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-fsdevel@vger.kernel.org Fixed comment. Removed explicit initialization for INDEX_ROOT. Signed-off-by: Konstantin Komarov ---  fs/ntfs3/index.c  | 7 ++++---  fs/ntfs3/record.c | 5 +++++  fs/ntfs3/super.c  | 2 +-  3 files changed, 10 insertions(+), 4 deletions(-)          inode->i_size > 100 * sizeof(struct ATTR_DEF_ENTRY)) { 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 *indx, struct ntfs_inode *ni,      struct ATTR_LIST_ENTRY *le = NULL;      struct ATTRIB *a;      const struct INDEX_NAMES *in = &s_index_names[indx->type]; -    struct INDEX_ROOT *root = NULL; +    struct INDEX_ROOT *root;      a = ni_find_attr(ni, NULL, &le, ATTR_ROOT, in->name, in->name_len, NULL,               mi); @@ -1007,8 +1007,9 @@ struct INDEX_ROOT *indx_get_root(struct ntfs_index *indx, struct ntfs_inode *ni,      root = resident_data_ex(a, sizeof(struct INDEX_ROOT));      /* length check */ -    if (root && offsetof(struct INDEX_ROOT, ihdr) + le32_to_cpu(root->ihdr.used) > -            le32_to_cpu(a->res.data_size)) { +    if (root && +        offsetof(struct INDEX_ROOT, ihdr) + le32_to_cpu(root->ihdr.used) > +            le32_to_cpu(a->res.data_size)) {          return NULL;      } 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, struct ATTRIB *attr)              return NULL;          } +        if (off + asize < off) { +            /* Overflow check. */ +            return NULL; +        } +          attr = Add2Ptr(attr, asize);          off += asize;      } 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, struct fs_context *fc)      /*       * Typical $AttrDef contains up to 20 entries. -     * Check for extremely large size. +     * Check for extremely large/small size.       */      if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY) || From patchwork Fri Dec 30 11:27:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 13084272 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 20D51C4167B for ; Fri, 30 Dec 2022 11:27:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234889AbiL3L1G (ORCPT ); Fri, 30 Dec 2022 06:27:06 -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: 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-fsdevel@vger.kernel.org Removed unused macro. Changed null pointer checking. Fixed inconsistent indenting. Signed-off-by: Konstantin Komarov ---  fs/ntfs3/bitmap.c  | 3 ++-  fs/ntfs3/frecord.c | 2 +-  fs/ntfs3/fsntfs.c  | 6 ++++--  fs/ntfs3/namei.c   | 2 +-  fs/ntfs3/ntfs.h    | 3 ---  5 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 super_block *sb, size_t nbits)      if (!wnd->bits_last)          wnd->bits_last = wbits; -    wnd->free_bits = kcalloc(wnd->nwnd, sizeof(u16), GFP_NOFS | __GFP_NOWARN); +    wnd->free_bits = +        kcalloc(wnd->nwnd, sizeof(u16), GFP_NOFS | __GFP_NOWARN);      if (!wnd->free_bits)          return -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 ntfs_inode *ni,  {      struct ATTRIB *attr = NULL;      struct ATTR_FILE_NAME *fname; -       struct le_str *fns; +    struct le_str *fns;      if (le)          *le = 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 ntfs_sb_info *sbi,      if (len == 4 || (len > 4 && le16_to_cpu(name[4]) == '.')) {          port_digit = le16_to_cpu(name[3]);          if (port_digit >= '1' && port_digit <= '9') -            if (!ntfs_cmp_names(name, 3, COM_NAME, 3, upcase, false) || -                !ntfs_cmp_names(name, 3, LPT_NAME, 3, upcase, false)) +            if (!ntfs_cmp_names(name, 3, COM_NAME, 3, upcase, +                        false) || +                !ntfs_cmp_names(name, 3, LPT_NAME, 3, upcase, +                        false))                  return true;      } 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, struct dentry *dentry,       * If the MFT record of ntfs inode is not a base record, inode->i_op can be NULL.       * This causes null pointer dereference in d_splice_alias().       */ -    if (!IS_ERR(inode) && inode->i_op == NULL) { +    if (!IS_ERR_OR_NULL(inode) && !inode->i_op) {          iput(inode);          inode = ERR_PTR(-EINVAL);      } 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)      return attr->non_res ? le64_to_cpu(attr->nres.svcn) : 0;  } -/* The size of resident attribute by its resident size. */ -#define BYTES_PER_RESIDENT(b) (0x18 + (b)) -  static_assert(sizeof(struct ATTRIB) == 0x48);  static_assert(sizeof(((struct ATTRIB *)NULL)->res) == 0x08);  static_assert(sizeof(((struct ATTRIB *)NULL)->nres) == 0x38);