Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2773274rdb; Mon, 12 Feb 2024 16:51:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjyvnlhm9Si8NdM8zELakuOvycm7RcvEDiF01ZJoiq8FNRO7gs+YeO3qeqQ2cq1d3cr1VD X-Received: by 2002:a05:6a00:b55:b0:6e0:5281:e0d1 with SMTP id p21-20020a056a000b5500b006e05281e0d1mr7535341pfo.1.1707785467261; Mon, 12 Feb 2024 16:51:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707785467; cv=pass; d=google.com; s=arc-20160816; b=N5itf4ybB1AG0eMFevIuw0ekYyg8SzZu3PxtypnZNQOi3YItKXCenxrinteTR4fDJc ukx5h4Ift4YpNMh2zBfkfIrN2xArSa/LgwVZUiomfHk23fxbEKO2skTppLNSOebEoIsy Aun/RoUKuWhEv9qkLmdG1Hgf2beLCNJzAd2AeYtVSfxqzlOASQPMu8uFyN/z63iYqEtH fsLi00WM092DyrP1WEJ1vz8BtmCxaH2rsMlk7RNuoN7vOm2ZhS5IUi9oOlinp7cY28Ti BFSGBhVZ+W08QB8wtsTADvvyuvImpNWzObgGXugbbrMjhUQDVf4tRYOtLpnHsKTxOIEK l3ng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=23QzRP0yVDX/zSieEA1zidprshdMZjCB6SQ2zvT/77A=; fh=Vgc5MPj734bsBJnHkBVGuCrOZRFxDvnENwEZOC4PuIc=; b=Urd/OUzUOWVvUbNZiOOnpBgJ4OAakJ/WsPSzpAaBEG/fJCQkiZ8LHD1vge2TJ8q0ys dl+XEpH2kkmOtMtapKHWYtVnDEqAV8tyilptBaCkr0bSZi3Lra5JTFDZ5jhDGYPUSJ6J 8gOuDXFiblNZwMxZw9AbCbXRJtXJvKZsVDMALAB+BwYdsKCGxdDcnoZTeN9vFYOCyQ1R l6b0eOx7MOh8Tff6eQRTuXbrei5nnJLULOzOhInTc0zGpB7EXQrhQWfFmU6ZdNxYjG++ 2kPcCevTd5qCGURc6wT29cdusEds1jRSdnFTzK0HbiE0JjyswrOv1i/kNnfs2rYuoekE ld4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QRbzN7rV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-62689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62689-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUN770D77BpELLTBTlAov05ixBcEvwCMJ5OES6GoqhcDPi9tT8nV416pQloQOySwZGT/HOIsqPVw/TiHoU+3mcy1Rs+QxW4n9evdZ6aFQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bd9-20020a056a00278900b006e0f6eecae5si458814pfb.357.2024.02.12.16.51.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 16:51:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QRbzN7rV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-62689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62689-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E7D9F285071 for ; Tue, 13 Feb 2024 00:51:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C347477A01; Tue, 13 Feb 2024 00:22:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QRbzN7rV" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB1E477643; Tue, 13 Feb 2024 00:22:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707783764; cv=none; b=n1oQ9jGrAdihkA001O8Rx8Yju/aAHzfAWKMfFuCN5CdRWjG3bH/1cDDwv0IfbOwHHzEd0EnmiWDtgGHf5JlR49KtEiEwcpYYbHlyPqeLUqbsNN7w0Tys7fYL5iWf54ftOswIkjNW9oHY5PsvVvUU7tP0eY8zc8whQCbrsEQ6yzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707783764; c=relaxed/simple; bh=O6g1VVx5QMh4Rrd0SWjyJShEcGSxkSd2Ea0RIaJqiqA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nOT524HYwNgYaavNWgA3jiZZWYSgTh4o0/o75e4u0p96SSKCkyZwR7F1bH8fxckwvAf5vrhVORvcA3werc68J9eCIm2yrcpaBoDbmVjJCSZ/n3pR83Bsx+fd8iGtlmGi431NoSQ1dYguFh+pBKLxpyQMUXta8AXkdK4VOMEJ99Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QRbzN7rV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB845C433C7; Tue, 13 Feb 2024 00:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707783763; bh=O6g1VVx5QMh4Rrd0SWjyJShEcGSxkSd2Ea0RIaJqiqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QRbzN7rVDC3iWP1lG1QE1QNGpvl64213CHkSICFb7c7320ZAt2t30q4GSKy0RpXPP IA3LfRMgiOmq2c1Tl+cB1XLeuuDV1hXqPMQXwheZTKXfGoey6ak8LE3W51ymjQ1uKn 0MR5GFW7pMRB8alJeJoHV5pS0U/pwoSlAERMRwm+q4gWmhlP7Ls0qYTcr3bQDI8Pb7 zRC0r3g9BtWiEKKOyr5xhc8Xu+NDeUtlvXRP8Kjk+/DzHdjRIxtBE2GyaoxTOnGl36 adZYokjrZ9VJHozw9bslcVo8GK5lFeyIpDHe1a5/q5C+C7xYegXQp97my3kzXWA14z bFcqlHB8Nq4VQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Konstantin Komarov , Sasha Levin , ntfs3@lists.linux.dev Subject: [PATCH AUTOSEL 6.1 06/28] fs/ntfs3: Add NULL ptr dereference checking at the end of attr_allocate_frame() Date: Mon, 12 Feb 2024 19:22:04 -0500 Message-ID: <20240213002235.671934-6-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213002235.671934-1-sashal@kernel.org> References: <20240213002235.671934-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.77 Content-Transfer-Encoding: 8bit From: Konstantin Komarov [ Upstream commit aaab47f204aaf47838241d57bf8662c8840de60a ] It is preferable to exit through the out: label because internal debugging functions are located there. Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/attrib.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 2215179c925b..2618bf5a3789 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -1658,8 +1658,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; le = le_b; @@ -1740,13 +1742,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; -- 2.43.0