Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2105703iof; Tue, 7 Jun 2022 19:56:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/9KW4vMszuuhHxiK7LrXKl9MSaieJIR1YgqXDp8VRxtwDLvZ+8pdWcswATskX2CCboxZf X-Received: by 2002:a17:903:240a:b0:14e:dad4:5ce4 with SMTP id e10-20020a170903240a00b0014edad45ce4mr32931725plo.125.1654656993544; Tue, 07 Jun 2022 19:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654656993; cv=none; d=google.com; s=arc-20160816; b=bWgwgxg02fzv02mgq4xx4MsfV+zYnkxHfA+/hTY0bXHT8IhrT2WE7xLHVeJqBk3cZX smE56oQSahoQ6H+W5xuZcia6qSlTeDc8FlYRCH/lNMB55qtE3+kwIDganPFOexUvtjEr 9mN722J1yy8+b4w+LOIFt7EwY1ezj0ukFvInWhvdXv2YMfMRHXlngQeMMYjQ215479Ft wZZFkr3qcGEVx3dFufNgRy5oZIzxizFqbi+TPxvi+ppYMtu+iY/GHe4ckPNMZ+bgHDxT XlMxFzOYKcSKnWWmh+YqH28WR27Khs6tYXyWKPK7c+juNDYmh7Yzpd1rKtzNj5jexKUr Wzew== 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=Wu+XFRDGTDYLkAYl5VvXtorF3LtK6wt5HJIEf5bKUG2UrNmaY5x8PAf1roSogMQV4D hfltn/WXV9/oo72KBtkPp24oXpx9SUhGESjyuyfGQrtlT0hQJkV2riASbB+AsNgZyMWX r6rvlMrjnLJcqSGIQkNxiKtciNkeNHKG/wQJ9V70esG0Wjuq+zhKAGAh6kJ6u+hFT8SD ZDa44Fsyj96Kc39VNY+WeWCZWQ/H6KHCEcj4NEMNskmPDA0CQsTCwNfhWJ4TqP1Lt9Y/ GtMbBe5DhVSyaBvUUFd6ECrqEvtRaqBFs6kad8ss2DZOVnxd4BQfCBKYP/IDaSkBe5xG 6yGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TYxilvcO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x14-20020a056a00188e00b005061eb330a1si28840559pfh.351.2022.06.07.19.56.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 19:56:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TYxilvcO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 51D1C32935D; Tue, 7 Jun 2022 18:47:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356308AbiFGWCX (ORCPT + 99 others); Tue, 7 Jun 2022 18:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378609AbiFGVDM (ORCPT ); Tue, 7 Jun 2022 17:03:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE451455B8; Tue, 7 Jun 2022 11:48:35 -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 ams.source.kernel.org (Postfix) with ESMTPS id 4CE6CB8239A; Tue, 7 Jun 2022 18:48:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB6CCC385A2; Tue, 7 Jun 2022 18:48:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627713; bh=sXhJAaUuI/+gq3WeDf4mmfghVWZcp4jTAcy/lc5Txhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TYxilvcORvrNH/fH0N3rcz1YJo96SM1rauqUL7CXBXO56hVaAHVD0xe6s94tjaFi3 vA2/aD0QdHZY2Qz/OC1XznkIE8mlBBv8ArX5/JMlzGhnEsy+qnzNVO6uLrBNwoxV88 rUo5/SYhgLwURBEla3OXXxxvwuETwz8KoJqBeTog= 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.18 025/879] fs/ntfs3: Check new size for limits Date: Tue, 7 Jun 2022 18:52:23 +0200 Message-Id: <20220607165003.406662524@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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;