Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp229041pxx; Wed, 28 Oct 2020 03:28:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycZ5E6Ao+YczwwmhSNT9EmuO78jYp9XoNEaTDgm2QODbc9lnArSpk7+v+T2KOfBFoIkNvc X-Received: by 2002:a17:906:5618:: with SMTP id f24mr6613233ejq.86.1603880922876; Wed, 28 Oct 2020 03:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603880922; cv=none; d=google.com; s=arc-20160816; b=lvD5898Qlhde1ifjTy7Y+Xa+4nlN7wv10Z75vdQsIc2K7alCpbzX1gSpWAcvXf2mM2 F99yNVtWiRapgV+fUX+fTrBGnRdxsfml250JBOMTHbJp8e1AlxrBfeLAidIBnPxgUUpa MCE1Vk0tAlKDbyD94BUB3ebeTgbwkB/Fowvwt0gI2QZEmkXq8USn9X66nPpcEX/wjYze Ik2Ej6epH9/SxH+DYyb9f/FaLD6hndzFXhxknPvvVDZPvQtNFMR1OdSSAkfixQGNKseo 1Go8/8rrU6B3dLc90UDPEpFBL5CsrI6O9371Vg1c3TKeYGz7E3o1bNBTkO+aiFQc0Jrv h7WQ== 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=6VBSD2OSL4oTaLPQgHijSRbc/FXxKNZI09IlRPQM7Cc=; b=OYOoYyxTw/fxL97oxXP2FlY+7luHgBVCGOa41EvMDI+7GiXm7sljOjiRZnU9UmugX4 r5l5SENAIcZ9Ld7GxsuyQfwHTQnAefKKEhe1Dw/EN+OLr3/BSNqCasIpp/DUKe/tcjQg yzzPKrB1MPqoaNa4CBkD0dvCDB0Gl0T7SCexvMhD45KhN6VSww5UpJgIMEbsE/00Rluq oSn73ECyhL3omRV6QL8Mw9cLHVbyQYMFO9UpvPwiVMmy/fjZgXcgiLhIA/XS1mhpRzMb GRHYRh04L8XpKhJCDYexv42WU1Jy1FEBvZuxcrhRhPvn46jBGsmIxTMCst2F3/+kSAkJ 6Y3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RpxA9v9s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jr1si3058858ejb.164.2020.10.28.03.28.20; Wed, 28 Oct 2020 03:28:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RpxA9v9s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761444AbgJ0Olu (ORCPT + 99 others); Tue, 27 Oct 2020 10:41:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:39200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761524AbgJ0Oj5 (ORCPT ); Tue, 27 Oct 2020 10:39:57 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA47D207BB; Tue, 27 Oct 2020 14:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809597; bh=sGaL95rRbM6Xb0b0k4a0ZZs9+QinxU6WgZWQsL7BSOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RpxA9v9sdnDFznSsrnUweKKMMefY33yiXlixEsEzfMl5OfjEDGHUHY/2c6ktALDM+ zHkIS++akXCWN/F1NUX9j5Tb8zs0T+aaV9HUsUXckUDZaUzSUbySMPBUvu6UPmSA8X V5GaCxAtUhDnMqTQZoiPf+4WR3mnAVrMa+X4RRXs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Christoph Hellwig , Chandan Babu R , Sasha Levin Subject: [PATCH 5.4 213/408] xfs: limit entries returned when counting fsmap records Date: Tue, 27 Oct 2020 14:52:31 +0100 Message-Id: <20201027135504.973339803@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Darrick J. Wong [ Upstream commit acd1ac3aa22fd58803a12d26b1ab7f70232f8d8d ] If userspace asked fsmap to count the number of entries, we cannot return more than UINT_MAX entries because fmh_entries is u32. Therefore, stop counting if we hit this limit or else we will waste time to return truncated results. Fixes: e89c041338ed ("xfs: implement the GETFSMAP ioctl") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Chandan Babu R Signed-off-by: Sasha Levin --- fs/xfs/xfs_fsmap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c index c13754e119be1..5b864985bc648 100644 --- a/fs/xfs/xfs_fsmap.c +++ b/fs/xfs/xfs_fsmap.c @@ -255,6 +255,9 @@ xfs_getfsmap_helper( /* Are we just counting mappings? */ if (info->head->fmh_count == 0) { + if (info->head->fmh_entries == UINT_MAX) + return -ECANCELED; + if (rec_daddr > info->next_daddr) info->head->fmh_entries++; -- 2.25.1