Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp594681pxx; Wed, 28 Oct 2020 11:59:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYy+lBHlAan+cfdudlTl5i4y2HH/GGtJa6HrnIvAtigAsTXlOaeJf3PDU3CK7SypXLcl4g X-Received: by 2002:a05:6402:1d2c:: with SMTP id dh12mr332111edb.256.1603911564020; Wed, 28 Oct 2020 11:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603911564; cv=none; d=google.com; s=arc-20160816; b=cgoSg9Y5XjTTn8mTQjD1qAXfr2FsK7V+dVH9Kx6LXchSBpX/rdfYwi32899/rYlEkb IOHNCjeGW/aCDxSMGjQpekXQMCuZUd44PGBN+BC6nQ4iJ6TMg8hNEJY2nl2n8F9fQC1I tsUUdFh0viY/DW4s4R7rtFYMPHOKXp6p+X9NEOlTNsDKzlXbTcG2HyQUdhbh+35do5KY nOCgRgcC83ZbA+xo2T2rlOKkzOUdfLE1j/fl0do0k9KTx3W4XvtOX1m5RWFJwYe54fSG 80jncQqSt0BcC7VC8TTxoFBuIPBl/j3xo8SgKKquuxC/29dmBmj1pCN8CeDJVpZIX8UA P7zw== 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=yhE9odlxq1+gacThflBofm1qVIcxXm2Uh+B0bWJI+TY=; b=dBGi7uLgkgiSKoeUWvrMkNFYIj/k7MySm43UuWWAHxMKjaKvuMSEHSg4FWFYw6zlp+ laLhHe/jCh8PIVcUr1VY6baC+Z6H+7U9/xtpJngav6jnYq78dGU84rOclAgw4XDRwLV+ FcdzK3oMabnbesKzFCUSs3JI67/WmmNGBlAT+6rsfhWZvzLQB1B+hYGfTyT/4RE//cj+ DXRNU45Ai+I+vwW+XMloIzftJdURUKMiXpbSGntSaxj94fhKHP97mzEjkqlJhg7xIxJ2 +Kua66Ka5n5K72YZEK/e+r/HqTfYTuoRdgCMu4jq6NnMSQWBiP+UWgZLkdLI7X8u2meM PP4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f6AwSWZ6; 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 d23si26051edr.183.2020.10.28.11.58.55; Wed, 28 Oct 2020 11:59:24 -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=f6AwSWZ6; 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 S1826089AbgJ0SQG (ORCPT + 99 others); Tue, 27 Oct 2020 14:16:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:33246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756236AbgJ0OMJ (ORCPT ); Tue, 27 Oct 2020 10:12:09 -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 8FD882072D; Tue, 27 Oct 2020 14:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807929; bh=JNX1b1s1S8/slQjwsPJ324lvjzzJASKZch41UK6bUss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f6AwSWZ6+aGw4ogLiB4noR134+LYtaUIJnGzAgCk/NVkxWC7iTS3V+6Rt2CKb4SmL Epoayvlj/dN6RsoSL9iBfAqUWeYb6cz31Z/WGgv8MBUVwB7OfBwZZTq5cYKB+E9hAV 8ylRwt4u7AYwLuPgTR+94bTXGlWCOekmKnqygjiY= 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 4.14 093/191] xfs: limit entries returned when counting fsmap records Date: Tue, 27 Oct 2020 14:49:08 +0100 Message-Id: <20201027134914.166848771@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134909.701581493@linuxfoundation.org> References: <20201027134909.701581493@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 43cfc07996a43..e7622e0841868 100644 --- a/fs/xfs/xfs_fsmap.c +++ b/fs/xfs/xfs_fsmap.c @@ -273,6 +273,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