Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2163281iof; Tue, 7 Jun 2022 21:51:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfCuyvNsvzhNfo3eTDcFdohSChZum2ELa/A6BNlPt9K+RD4yqMgxjbnJT7aI0EemKOTdPf X-Received: by 2002:a17:902:7149:b0:166:4e68:5c41 with SMTP id u9-20020a170902714900b001664e685c41mr28331140plm.25.1654663911862; Tue, 07 Jun 2022 21:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654663911; cv=none; d=google.com; s=arc-20160816; b=W2gQdDsYuAtWas3+mAbSgkZ68gK5CRvXJLMOIy3Qcjjl5o59hrrpM/BI9UB7oiGR88 XmJzdegr6BMSxDGIH3LEHgbQpWA4FRtU+nCDacQ92EU6zNJLQU1Vn+TIiRWMG5dA6Obp RTNXS0EdsgxwHGw2/JfwUf0cYk0tsSglulvFjsWZhizVi6+jwsVwos0wusMkLlhZz9gV hDnHGZ+SZvsp5umxb3UVmagEYPTzN7p4vl7w9ta/OAkLCb9zFcbbNopJP5LjemJwH8jV 5y+80tehSlqQSxM8k+TKQ5VuQ9xXe8zJjwXiQSw2UDwEwpz9nfb1vmEon0CQCNFLSLH2 M/8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Bi/5+Tw7q4Ck/01KWRRNpl8MqrjlGYdemtVtLGsxRLI=; b=a4gmrAH+eMYCdzFfeOZkK/j4oZe5GSFvY+hJB9CRtJ48bypkypDG/a+Lnumw8w3FMY UQopvY/pnQFz+KrhEdaApzHeEtOygqRcWIubViGi2+BbGxJMw92ngVvH0h3GhyOHDrbv 8iI3TjqHw2ZVqWV1qksBDgkPEDV1LcZtGWkMXDIezZ8AQdNCAf0aelOJVKsNRK2JAy0d GxYdnS8yLlHaPt5G/XupDtDVt9fv5wG4E8NRYWr9GKnpeX8eFYuf4C3DqVxaI4/ZWjO0 4NS3UGYxRIdlWdaKH4bc4tBlVdYz8ibrl+Cov0URF3Bgv2avrPL232d06GTfWrIdAAqW y4NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j+DJ5vGY; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w23-20020a1709027b9700b00155d894798fsi25599383pll.362.2022.06.07.21.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:51:51 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j+DJ5vGY; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 64301313362; Tue, 7 Jun 2022 21:21:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358819AbiFGUSh (ORCPT + 99 others); Tue, 7 Jun 2022 16:18:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356804AbiFGT2N (ORCPT ); Tue, 7 Jun 2022 15:28:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFFEF1A1954; Tue, 7 Jun 2022 11:10:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6CAFB617B3; Tue, 7 Jun 2022 18:10:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DD3CC385A2; Tue, 7 Jun 2022 18:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654625449; bh=sXhJAaUuI/+gq3WeDf4mmfghVWZcp4jTAcy/lc5Txhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j+DJ5vGYRFgwVNZ9HeK8+N6Kz3yG6OHLIhc9XJttFjxa2CcyCrDlBqDJGvCuY/+// ZiuUK5b/bbbWiPMs4mndpp0SscGAVlk7qI/79UWzFyCp2/hhY9C0184LHTCfejlyS2 lpq5eCWE5I1U181pzb1x2CvyjM4+3+1nsnq+MZFo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kari Argillander , Konstantin Komarov Subject: [PATCH 5.17 023/772] fs/ntfs3: Check new size for limits Date: Tue, 7 Jun 2022 18:53:35 +0200 Message-Id: <20220607164949.697143067@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Konstantin Komarov commit 114346978cf61de02832cc3cc68432a3de70fb38 upstream. We must check size before trying to allocate. Size can be set for example by "ulimit -f". Fixes xfstest generic/228 Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") Reviewed-by: Kari Argillander Signed-off-by: Konstantin Komarov Signed-off-by: Greg Kroah-Hartman --- fs/ntfs3/file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -662,7 +662,13 @@ static long ntfs_fallocate(struct file * /* * Normal file: Allocate clusters, do not change 'valid' size. */ - err = ntfs_set_size(inode, max(end, i_size)); + loff_t new_size = max(end, i_size); + + err = inode_newsize_ok(inode, new_size); + if (err) + goto out; + + err = ntfs_set_size(inode, new_size); if (err) goto out;