From patchwork Fri Oct 28 17:07:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 12495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp945418wru; Fri, 28 Oct 2022 10:11:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6DfIw3N1+Fh/eQtqgIvhYNQZNbs79kFa+PVVgZ4l1PE9v65bmjZ+y1GejsGXl9h7XOa30Q X-Received: by 2002:a17:906:ee89:b0:73d:70c5:1a4e with SMTP id wt9-20020a170906ee8900b0073d70c51a4emr275208ejb.683.1666977087475; Fri, 28 Oct 2022 10:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666977087; cv=none; d=google.com; s=arc-20160816; b=u2q1EsN+aEob4lMBDLpt6urmVggdFbucBmEQCth8aJkMDc0dbhN9aQ1GsXGAotc5FP xH4WkEMMDqRQ/z4lpRovM7l0+dSR4UnXuKDO9EhfVMPKEo5OTXbURWuLgitEDMtj+bDL FkrMpWB2ywHP5hc09vsGFkFBj1r2CvyPYl00WVwAVoLcbaIz1krn4gOuZbiwjRJt12nO QbLe+3MnbVkIAd1isUjnWp5U+/lCTC0AxzKm9GXKGUvzD6ZdCZFv6eQQt4gsUvZ5DFKF MWmmJW8fDGlWxM5hkXO/DL4X2GYQtPpTgVISnZiUJ4fBgtYfjOpYEYjmwYub72gK7D7W y0Ow== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c9-20020a05640227c900b00459528ef81bsi6335423ede.324.2022.10.28.10.11.04; Fri, 28 Oct 2022 10:11:27 -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: 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747952166163990855?= X-GMAIL-MSGID: =?utf-8?q?1747952166163990855?= 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;