[15/16] fs/ntfs3: Add NULL ptr dereference checking at the end of attr_allocate_frame()
Message ID | f876d196-bfeb-4b0d-bb10-dc793717db49@paragon-software.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4179803vqy; Wed, 6 Dec 2023 07:25:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqmPv/Y7vhD9Re/WQ/EOQ2J7J+AQdVdlwB5kJAQ68toSe2CTwe+NXFfd8HdTFRkfM5510U X-Received: by 2002:a17:90b:4f4e:b0:281:d84:a97e with SMTP id pj14-20020a17090b4f4e00b002810d84a97emr1374972pjb.2.1701876330355; Wed, 06 Dec 2023 07:25:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701876330; cv=none; d=google.com; s=arc-20160816; b=F1nFKw7w5BXu8WJxO89JTQBay+mhmIIjauQ1wJq3HHgUNZCcqOA4XTNR/FJoSjEzLT ONm9wNnS1WIEZmIaCtdfRscONggRKQVDp0pQvaDE3p1Kfds3Czt3geVEv8pqW3hJFyoH M6MiVYx0FhET0/sFyQTj8slVqTm+XciIKHClSOmGs7Ebl5eR5fUHpJe587BxWAGjYLLz /6WwW8lTe9rNDbulOKVOWVvjnR4M0a58BHwkMAqXz92KrIh4U2QsH74855Opyfu5jG6+ eIjpHXEqhIIkqSaZdOGTQv/gmf3qCkWMXQTn3wLrR0DHL6negwaUOSi23i5zE19519+5 6nuQ== 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=W/TNdgmKDqNDYIi7mUSo5ayyxeI6Wi55D54a4MJS5O8=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=CmzIGp1p0DOFX1nNW1YwZCpOPwHtvya8zKHphMumL5NvJNOABq468FlGF5QcPpOJ8T qUFQdHGgNtkLa3O2OUhUPg7LxYZaiEaJ7PAlSH8rMxRa6lfcks3yapZXX7WENozIDMCM 6UYTr3gbw+1XjAu+C7EIdnRfLkXvA+dyA/sVPneDOfZ7qjHQdQFiYCxyeVEXa+BymedQ 1oXMUmas44Mhq+yveJ3Rt+7XNvKQ9alUeZp3apOc3Ifc7cGlZ1q4fE+C/khUW8RjVHTb w8XGmAf0vH8geSh5tNXjdmUUFs382iniOsq/RlyjI3PFaXcCeIpK1tP8LGZZ5OWaUAdi oQnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=uB7SJ5ZV; dkim=pass header.i=@paragon-software.com header.s=mail header.b=HwerjDqS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id lp13-20020a17090b4a8d00b0028862f5a30dsi19567pjb.49.2023.12.06.07.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:25:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=uB7SJ5ZV; dkim=pass header.i=@paragon-software.com header.s=mail header.b=HwerjDqS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D2E2F81C19CD; Wed, 6 Dec 2023 07:14:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442537AbjLFPOW (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Wed, 6 Dec 2023 10:14:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442535AbjLFPOV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 6 Dec 2023 10:14:21 -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 08B67112; Wed, 6 Dec 2023 07:14:26 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id E6D181D0B; Wed, 6 Dec 2023 15:08:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875280; bh=W/TNdgmKDqNDYIi7mUSo5ayyxeI6Wi55D54a4MJS5O8=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=uB7SJ5ZV34Sc6PLOrZBUBpCENFmPGqlFtRZvqJoH9vKlKM7YeJH4IMKAHPy9I9iEa ejo/mhQFbObUfY7QSS46h7IJ+xwplvgdoZFTxSFtWgAmYnNnVdXzTJPHQhaaWOBNo5 SWLDXhH3caMbQcpe06yX7DO97jt+0K3UDKKUucwE= 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 32A922117; Wed, 6 Dec 2023 15:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875665; bh=W/TNdgmKDqNDYIi7mUSo5ayyxeI6Wi55D54a4MJS5O8=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=HwerjDqSLEHZuqFn+zzPuEhCBWA0uFcD4nADai1942YJ983cNo0j/pryidiex2rWP H0uuBaQ306w3AFnBoJcJRFcIIK8vQDQuWbmPIeusCe3s3FXdqFM+hDeHsYQD0L0g+x O29n04DNf2rqk9XpwAgCpKfKdguOdnw9nTpi3aCo= Received: from [172.16.192.129] (192.168.211.144) 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; Wed, 6 Dec 2023 18:14:24 +0300 Message-ID: <f876d196-bfeb-4b0d-bb10-dc793717db49@paragon-software.com> Date: Wed, 6 Dec 2023 18:14:24 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 15/16] fs/ntfs3: Add NULL ptr dereference checking at the end of attr_allocate_frame() Content-Language: en-US From: Konstantin Komarovc <almaz.alexandrovich@paragon-software.com> To: <ntfs3@lists.linux.dev> CC: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org> References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [192.168.211.144] 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=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:14:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784546674737446298 X-GMAIL-MSGID: 1784546674737446298 |
Series |
fs/ntfs3: Bugfix and refactoring
|
|
Commit Message
Konstantin Komarov
Dec. 6, 2023, 3:14 p.m. UTC
It is preferable to exit through the out: label because
internal debugging functions are located there.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
fs/ntfs3/attrib.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
le = le_b;
@@ -1825,13 +1827,15 @@ int attr_allocate_frame(struct ntfs_inode *ni,
CLST frame, size_t compr_size,
ok:
run_truncate_around(run, vcn);
out:
- if (new_valid > data_size)
- new_valid = data_size;
+ if (attr_b) {
+ if (new_valid > data_size)
+ new_valid = data_size;
- valid_size = le64_to_cpu(attr_b->nres.valid_size);
- if (new_valid != valid_size) {
- attr_b->nres.valid_size = cpu_to_le64(valid_size);
- mi_b->dirty = true;
+ valid_size = le64_to_cpu(attr_b->nres.valid_size);
+ if (new_valid != valid_size) {
+ attr_b->nres.valid_size = cpu_to_le64(valid_size);
+ mi_b->dirty = true;
+ }
}
return err;
diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 4b78b669a3bd..646e2dad1b75 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -1743,8 +1743,10 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size, le_b = NULL; attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, &mi_b); - if (!attr_b) - return -ENOENT; + if (!attr_b) { + err = -ENOENT; + goto out; + } attr = attr_b;