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: 37644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2843836wrt; Fri, 30 Dec 2022 03:25:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXti+B3M4fLvhotCaSx03vUcBDrHgWo8D+s1YK/piUpqeFB+8pyFLvtxzpKZFAIg73MGUwhx X-Received: by 2002:a05:6a00:4c15:b0:581:9313:26a1 with SMTP id ea21-20020a056a004c1500b00581931326a1mr9529586pfb.23.1672399533279; Fri, 30 Dec 2022 03:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672399533; cv=none; d=google.com; s=arc-20160816; b=Zr1fNuDRVbvJe8/kkA+qaTkvwe06tUNDU/YxfsROxUw55U6CEaKjbXlIlLiHRzLvl8 ovrC6JcO/wSyWt40l70OmLh4ZY90c7cxfDxrRlr+i+uJf9otFN4SyJuu6vASNem2QRH7 9Q4dcASw8yq10yaAXSQUZXGHLrmsIiQlAXphyGQxNQWGw1wQkE6OmOH9/EbYIn4dnuFa lrRwb0mxqD/7cxFrZ23bzqbhoT7yDSMaIOdW2jqhGtClwLt79Fes5Nwlq2eMIQkXAA6w /Dtt9qCDWLy3o98JOOPra8+ub4I8FMo6j218tO9grAn/S8mI4v1jpYejSPExtHUEdsrl zYmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=Twpu2s1FblETHbbeLRTjYS0t9CCid29iOzsPHx6E0wE=; b=b5jvfMVdeC2V4a0oYA0AgQciNnnuWUDf2aO5xmk40qwXtlm83P8/dYw9Lm/k2/R0Jw hRfBaKPM1jLAmFED1ql5wQWJXvHZYSb5nsHdhMR4GBVjleTuuiuG2HLBPzvO7SXeAYpz FQAjtqbybP78bG19nW6vSEk63nNkSPImshxmWDm3uA6kleRqqbiih+jFRWc6porFklhQ BGPEUkkhaa0m03aQwF1v9VCvrrebkb1QdimwUPcafi259Q6ljhLRuY1Tgjvd3Bh+Nd+R i/MISq15OKXjagYCuw0JS94V2UxL8bxKH0NueMaku4e47JZ4rwfi6L+y24H4wdfTaT+L 31TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b="QR5/iro+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020aa781d3000000b00571fe971a74si19702456pfn.41.2022.12.30.03.25.21; Fri, 30 Dec 2022 03:25:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b="QR5/iro+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234743AbiL3LYE (ORCPT + 99 others); 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) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753638013103167444?= X-GMAIL-MSGID: =?utf-8?q?1753638013103167444?= 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: 37645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2843975wrt; Fri, 30 Dec 2022 03:26:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXuvZOvIgcMzQSwBw6dSsWdAxVIuI3qdUW4sswQMzEvEY8T28YESP/aKeY6vuglSeq/N9znb X-Received: by 2002:aa7:914e:0:b0:574:35fd:379e with SMTP id 14-20020aa7914e000000b0057435fd379emr33136686pfi.2.1672399565353; Fri, 30 Dec 2022 03:26:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672399565; cv=none; d=google.com; s=arc-20160816; b=SQsqc9qRWycAaB6/SYIiSbsESHEFLrSp5uVMY8mbfvJqB9Ca+Nln3RGGFeZln4swnq 9975WRTPxy2ccllBDaA/J/ZKxqJm+AZ/ihMU2ACEbEnNPK7MuQU8o4NXSp/KfpmmS8xI 0JzNoHL2lqO0JAUen7K/3R8bm4YZnoFp0riXrlodNObhbesztafK+0kZy3Dxiv4LGFt5 o95xu4qF+1pBK1g8jKx1S0dt/qhiUaE7VWBWeemXv+VdYLW8pLRVqrA39veUfZ3TdaBa Yj2SCJsAiEUjCuOEo7EQ8bKf+70HADdM2AYoDD7qPSyp1RYf1IgLsLaBj1TfXqMfDSfF PSkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=IhyjcyPjOgMswqZxmuu5gRIeIvP7uahHFtRFs1brtbo=; b=QUfq5mNMg38jX4FrHC0Jw/DbVTfsCsCw9oL7uUxDLvGhjHcEkxPIu23c0abz1yIMfb yb+guaM1mhClGd0LGL69lKDgSH5vTVZqsXoSREjTrwaKyaUgleGRbmbb5i9CFDz3ctkc qbDUmTndIEBtfx661APkSEfkfPDuWO5j76vC+VEjAdWKoHbqrC7oxOcViEwDE3W/2J2V uZdWo3yLO6XJLzf/K5J7CgRLguwLnynKKEUUDRl0sEhyLsIc6c76ilxz9IAQkiCPzoLf SfwTope45t6qEfKobCEN7OQtuRvv6+4FGXsQAlRP34njlmSpUBgMVmbfSp4PUhcRIb4r 6TWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=fNkB3w4M; dkim=pass header.i=@paragon-software.com header.s=mail header.b="S4C/nd8Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a056a00088c00b00580e8dd6cf1si17409507pfj.73.2022.12.30.03.25.53; Fri, 30 Dec 2022 03:26:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=fNkB3w4M; dkim=pass header.i=@paragon-software.com header.s=mail header.b="S4C/nd8Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234766AbiL3LZT (ORCPT + 99 others); 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: 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) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753638047059987590?= X-GMAIL-MSGID: =?utf-8?q?1753638047059987590?= 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: 37646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2844155wrt; Fri, 30 Dec 2022 03:26:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXu5ggvhEW2rXX9yOEbKsNBJTRgCgzKuHtYwjVXKrMJDgOhnNJ8xZdBXuJ3/EXmPgYul8Tv+ X-Received: by 2002:a05:6a20:4295:b0:9d:efbe:a0fd with SMTP id o21-20020a056a20429500b0009defbea0fdmr50260745pzj.13.1672399598205; Fri, 30 Dec 2022 03:26:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672399598; cv=none; d=google.com; s=arc-20160816; b=Lw2Jvk7/rfQmxG6up/rHpyPFMspjjhtoheHllKLUlYPNbO3pvfyBY5GwLNcQgwFRC2 m5+r3QEl1qe8ciwPNTZ+/krlIjxYbD6ZF55fZPBZsxXfDH78AkXFCQ5dJXWcKJrQ8L/d TsVlzz/yakhfklNa3N0nBN6BsMmdgORVftjgGri1FsvYwlnIfJBAq+LdmJVmwGl5EQNA UyM5g/y/wJ+SEsXyhsY6vHtEWoDR7IGLuQ+ChMi+BuNXsXoItTUQcW+4c5Z0WeKcIyRk TTKI2dmsnv3rtukSsvWMIaeyQx3fy/q05ifowm2EkPwHDDoKmzRLATj4mmP+yIMNYyad kvFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=snwY2+VKm0LsKlpAvdxmC463EUj3w2PVok9aOOZl/rI=; b=VJgclyXlwm9BEVRQswpLFJLIgx16UPfrJo9lRR69QP/VnJU0IE3ie+rKIYIQTw1PX4 cHshEGLtoCWv82UMnR3Na70PgVomJARu1dcqfQCpNYdRYcVRZA9XXZI0eD89mkkj8TTN wYMuqKD878EsUFO7sNCTMEfm72t+cmOwUuZMbCOz3igzmY6gDoH1PAt9ijVI+SrAx9AC F8luRHoVIal5AH3Qi9qylOUyuubN8dg2ziDvwET7CF3XzIfY18wjtRy1pFHbvpDKABDl +R0mz72V0ZtUg8BkcnQZixaCKUhjxCho83p5nINi6yzPZrNbbXI1Hzv2zAIuE6uvjLOD ngdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=rRz9SCjf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w184-20020a6362c1000000b004403ddda6e6si22672427pgb.847.2022.12.30.03.26.25; Fri, 30 Dec 2022 03:26:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=rRz9SCjf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234805AbiL3LZx (ORCPT + 99 others); Fri, 30 Dec 2022 06:25:53 -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) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753638081048068120?= X-GMAIL-MSGID: =?utf-8?q?1753638081048068120?= 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: 37647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2845200wrt; Fri, 30 Dec 2022 03:30:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXtKbIUbYrswmJf5oK4CEo3jYfMLVGHpWcBvYgZ1ooUt5cHCP3JKWTiCsFsdygBkjNRJ+MAl X-Received: by 2002:a17:906:311b:b0:7c1:64dc:ac25 with SMTP id 27-20020a170906311b00b007c164dcac25mr26986145ejx.23.1672399806524; Fri, 30 Dec 2022 03:30:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672399806; cv=none; d=google.com; s=arc-20160816; b=KTYTaf9TcgwpXHlHT3sHoA7JiVxa0ectJKtuyKWxDju/I/fVH/3Nnox5Sa/71ASOTp mLa5F8QW3hwL0v7kf9tEaDH/NUci01T105yLhzQcyhaQXVLrH4RecO9jh6LaKD9LrhpT OZ6dQWkxs3TI/6okso9hnQycoxr5Ab364QxVAnfodaUJNDUzhWllHDgRvzXcSZrDfZqB yGP2Nzz+Zd3/MebfsHMwqECeg1X8PaXnTdkG3vj4k+qVodsBz5bsiF1ydfMNzPl4AyYY yevheNsOmK1wQx73V0VUY98o70QBMhyQ8S4owu8+1WDXlNvC9e0T4Nis26vVVVNoshid FkPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=cx5DEN5yzbTg0lbldjz4Ma6Es6+57SY1O3L9oJVV9ds=; b=hGUSKZ19eqjvA9IKl7+6jzAUW01dnPzp3nyF4IPUsJpzjU0ZD/+nL0J1hMl5xku6Sp nCsNNAuNXn5wMwrxer+DUWFM2G84dRSNxMf8VwATmrMPnCn2oZbfJe7vbO/uPrrxPl+4 vB9KU5LVRX6YvT+YKofwZVznscs0fG9wxjeAcW3ruTNrxOoZoiY5iTZh60nZ2U0Ls1mF EYeLbwbQs6uVw0qVLiwCuWo5YKC+79EFOxerQ2tRojlQXyzvfzp1kEQcwFZh5reTtVdV 2KOMEMONsYf4P+Gw32+ZXUPRae38lhqIoIr1PXjbCbIMcWzK4mbV39mjFhXuSfB6+34K EDcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=rOEzMTST; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a170906848700b007a45e4f4ff0si15512540ejx.885.2022.12.30.03.29.41; Fri, 30 Dec 2022 03:30:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=rOEzMTST; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234850AbiL3L0Z (ORCPT + 99 others); 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: 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) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753638299660939388?= X-GMAIL-MSGID: =?utf-8?q?1753638299660939388?= 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: 37648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2845633wrt; Fri, 30 Dec 2022 03:31:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXu9UFuidylci9EUnps/KCo9sg2qXhPle9a4yEyDTCbkpA6Xz0G+zOiE6MP3W8PYQrIUjsX0 X-Received: by 2002:a17:907:2155:b0:7c0:c1cf:f9e8 with SMTP id rk21-20020a170907215500b007c0c1cff9e8mr32265988ejb.30.1672399865476; Fri, 30 Dec 2022 03:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672399865; cv=none; d=google.com; s=arc-20160816; b=ysXz7p7sZNySxIoPQIkYHYdHeFrrmCpKvTxg2yTbKAVE4XT1ehDDLmuehYwuyq03Of gMbjtuOGcDI23zBhH0kHoUf9esiJaRbfSrVi9mIiMWVyju/uWEdW/lBQCe9iSIV4pZJC oxEymU7Ejmp6Wb++pj1Kd9MvsVOW4XBpYD5b1ziSTq5wvXssE4TM6yN/2TwiBvSYMbx5 OlqaWhgdo7PvevNcrq5Oyzo7/yhkSa3tvavnQm5CtOl5Od7usMl7QzakpyAkjCq2VmjL rGGyiVSLyM8Wr8QIG5P/W6lIX0OK0+YMbINJF9DTZe2qiKDA+ehlKSHXp3FD0N/W4EA4 3mqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=ETfFUvoUKgLpON3I17vb6pr52MbHQUStImHG554hLLg=; b=TZCeUMIO7B9go9U4zyFYcES+Wp778KdKfraKWxjUGT8HvvjUd8CPnbbPIPbKnKHY9c A3gV/yCH6/AN0lejSh0VelaxxDXewfSBUzzCUa9eC1/WZVohAjg+kKz4g7yujFmWjKaz iUJCcuVP3k0gMZs3um2W3LQaa7SalTSH1+9hHlW68r6+7zN5E5yZsq0QwaGX2GhoDaLV +fyCFF18Vh5CBIrCQr/MIrXmxURmccAmeTPjSX+d+ywCBwcjQqJwziw2GKz+AXMZebZ1 QAmV/bxIoJK6FyZ5MzFJJevazRR/iAzoeEetZzehqnKLzxOpEMUNy1XXFWYnXfPdP38K eKnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=m3uMIOY0; dkim=pass header.i=@paragon-software.com header.s=mail header.b=d+FBdD87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xj4-20020a170906db0400b0079800b8172bsi18694014ejb.450.2022.12.30.03.30.40; Fri, 30 Dec 2022 03:31:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=m3uMIOY0; dkim=pass header.i=@paragon-software.com header.s=mail header.b=d+FBdD87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234904AbiL3L1H (ORCPT + 99 others); Fri, 30 Dec 2022 06:27:07 -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) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753638361723792543?= X-GMAIL-MSGID: =?utf-8?q?1753638361723792543?= 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);