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) ||