Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2771060rwi; Fri, 28 Oct 2022 11:01:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM672FcGPCAzWrzXNh2ov0npway6xrIcMsGghI40zSRICL3mrbgIpQP/HebZMogz3W/rqyVr X-Received: by 2002:a17:907:270d:b0:7a5:f25d:9efe with SMTP id w13-20020a170907270d00b007a5f25d9efemr526874ejk.640.1666980063255; Fri, 28 Oct 2022 11:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666980063; cv=none; d=google.com; s=arc-20160816; b=JEarR7gB6W2FRmKEQHkp+xNseRN9ddga5vU7NwfCuL6EtOlfQd53sq5nhQFUc4FiBp 9r2gfg5ZUk9EVa0dIU6c8OGSt4UD/KyZ/7TP7qRU3CiCiAN67b6AFKl/6eOvkaEknwbv 4JnOIpxNHevw993X5XWCTM0tcbi7JM85Y2esMK6S+voZROi10FSCSNg5HdyOm4d8aEiZ yFWb1s0bNjWn/B09C9oXR9T8swywGGeL5YndzTcInJCSzbFbEB87qLOh5e89Ndo1eG+q n8XxyqrMQ5s5WQt9lO+6hpLN62O5mz0IYc2g4ulkcQUOYZcnyNG0DBubvMVH4sNt3HW1 feww== 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=U5rbfGUDH6ccvvDNl8615tsqE6RiTSqFhdpj1nt8ic0=; b=wmxe9BKa8ZNAnrSc5TFZqvx7w+nJokUJnrF//h4CU2Ovr+r5wBry+lhxIMGQJ85ooS T2hSzN5Xm7aL2+AYL8PzYREih5uOXY5VdKzNRPiJnFhwTttHrYzTnROAdG1gFcJ6Jpwb Kki8cvvWVarHwgWiqcDGPv+6NxUbq3XVZSnukHfW+GbVgDVtC/c9cXvwPLwmpFXk09Z/ yGYqD5FVkc+CgKUt65lBahaweDLg08i3cmpIEAairdao00t1beU5U9gc8WgGlRMjMSvq iVNJ/uzSKYQ4aRIBtz/yu6NGHL6jbhjlogSlN8DVABIFHJEg10Z3Nlay4zifigmCSTpK /xXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=hwSGfoen; dkim=pass header.i=@paragon-software.com header.s=mail header.b=YE23VZEz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 2-20020a508e02000000b004513abe8f74si4707662edw.249.2022.10.28.11.00.36; Fri, 28 Oct 2022 11:01:03 -0700 (PDT) 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=hwSGfoen; dkim=pass header.i=@paragon-software.com header.s=mail header.b=YE23VZEz; 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 S231362AbiJ1RKd (ORCPT + 99 others); Fri, 28 Oct 2022 13:10:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbiJ1RJx (ORCPT ); Fri, 28 Oct 2022 13:09:53 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FF0C23AB70; Fri, 28 Oct 2022 10:07:24 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 470E5218D; Fri, 28 Oct 2022 17:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1666976683; bh=U5rbfGUDH6ccvvDNl8615tsqE6RiTSqFhdpj1nt8ic0=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=hwSGfoen1bMnhsSlVk8x6dEwrUSpuNPsLhvXJnARtw5MNCA1r1KWx5dao/d9v3eoK 3Vu0+WppGF6nw8xAtqoIFmKwUeTp4O6J0hWqj4kSYi6HnXd+awtcyeNNgCn3tlbZKA 1t3QcY0SwItky4YG4Lokvq28mmbaDSV/EgRIpuxc= 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 43FAADD; Fri, 28 Oct 2022 17:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1666976842; bh=U5rbfGUDH6ccvvDNl8615tsqE6RiTSqFhdpj1nt8ic0=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=YE23VZEzseXPeW66Goh/t49OwxklhqLY0j5wtbGtZJlmHCCVtuQILU9sJbZDgZGhe V/SolDCexSsbF+eOmm2OHKN394ShVLf+z5SdQP1IImgkDMogC/9hLKgi6dk6LjIZ2F hkSWbWe2tNdvhcDZnm+36N8X+jIZs0VEiOD0EAyM= Received: from [172.30.8.65] (172.30.8.65) 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, 28 Oct 2022 20:07:21 +0300 Message-ID: Date: Fri, 28 Oct 2022 20:07:21 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [PATCH 12/14] fs/ntfs3: Fix wrong if in hdr_first_de 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: 7bit X-Originating-IP: [172.30.8.65] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) 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 We need to check used bytes instead of total. Signed-off-by: Konstantin Komarov --- fs/ntfs3/ntfs.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index 9f764bf4ed0a..86ea1826d099 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -714,12 +714,13 @@ static inline struct NTFS_DE *hdr_first_de(const struct INDEX_HDR *hdr) { u32 de_off = le32_to_cpu(hdr->de_off); u32 used = le32_to_cpu(hdr->used); - struct NTFS_DE *e = Add2Ptr(hdr, de_off); + struct NTFS_DE *e; u16 esize; - if (de_off >= used || de_off >= le32_to_cpu(hdr->total)) + if (de_off >= used || de_off + sizeof(struct NTFS_DE) > used ) return NULL; + e = Add2Ptr(hdr, de_off); esize = le16_to_cpu(e->size); if (esize < sizeof(struct NTFS_DE) || de_off + esize > used) return NULL; -- 2.37.0