Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp234985pxx; Wed, 28 Oct 2020 03:39:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJgjNGoA192EkTq9dOGci7rOU8uB4ywuOcNCdv24eCB/kUQfTmcknKk9Xo0jD7NOCH3FJR X-Received: by 2002:a17:906:edc8:: with SMTP id sb8mr6658540ejb.241.1603881581170; Wed, 28 Oct 2020 03:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603881581; cv=none; d=google.com; s=arc-20160816; b=RR+0WjtIJJwXvjjw7pSvV2EfnvbBYxxHv90RIKUhamgMY95oXtdyfG5bIsI+wCBRFK GpVCUXB6at4E3ES68oJIYRKfqooT++qUYxOxlGpjI4/W34uamzidwjFjpYk9hF8dkG9O c6cyA0/SK6oS+u6xdOKsgosgpVP79aYNeCrBqYmgenq88eforumfEVLYvU48AXmExTNp gsHn0ZBi++JgeJQQhZ2H7ls8isEocLiiZy9H4+q66GsAzlyNIKqrCR5QnjEb44hD6vKu 9RdvKQFOcZNP5y8sCCGzgaWd6LSSIKUIVL311cTPnEDOPUN8WFSWBa8dqirvYAhsrBpG MaRA== 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=+cimystL12ReNYs32Q9bQ7x1mZB37AsVF/bmHvOPOLI=; b=bDEt3br0/9w1rEMrwnCDBaC0xxQ+RgHkqa9RCr+6/4GsfP0N/mWUzpGft7OlH5+C7h z2FQAQYaE1SEuWkmnLBr468jATaRms6bnF3ajf68lREvVBsmmgYMhBWkvMQEz9K0nwaS NYUqwijQLjkWyu+QbXpqjWUnwYl/waqS/cez1P4pwMAd1GK/oi97yEPsfgzHrRZScpRu FXkg+6sX1gwkxWRypkjDdA8p2blMGehFh+siLMBavEJNY5af4SyWM8u1sbgjezggad1h 4dgcSYMf8fjtJesMMs65BUXZerxbND4YZ84Gv6MYpWS0+SaqOGlYllyKnPpUG73piIjT mHRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yIOCiarO; 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 f19si2736409edx.542.2020.10.28.03.39.19; Wed, 28 Oct 2020 03:39:41 -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=yIOCiarO; 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 S1762807AbgJ0Oo3 (ORCPT + 99 others); Tue, 27 Oct 2020 10:44:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:42896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762487AbgJ0OnI (ORCPT ); Tue, 27 Oct 2020 10:43:08 -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 CC1AE20773; Tue, 27 Oct 2020 14:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809787; bh=qoRhQuQEV4CKlz3qaWNl7/xqZX+AF2ooIstYglQn92E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yIOCiarOh+gzzBKLQb23NKqyhN93uemxSRDH80XrqIeMP48oPEs5TaY74HQUz33OI dktbyr52aIc1JYVyVTGkirXTpVltMnVGH7os0hVtB0XgBZmrbp6YzGuZv/h+xR6hol d6WMnG3rQBsBpOqbt6J/pdGu6kDXjhLCrIKL5+J4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Theodore Tso , Sasha Levin Subject: [PATCH 5.4 279/408] ext4: limit entries returned when counting fsmap records Date: Tue, 27 Oct 2020 14:53:37 +0100 Message-Id: <20201027135507.983936925@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 af8c53c8bc087459b1aadd4c94805d8272358d79 ] If userspace asked fsmap to try 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: 0c9ec4beecac ("ext4: support GETFSMAP ioctls") Signed-off-by: Darrick J. Wong Link: https://lore.kernel.org/r/20201001222148.GA49520@magnolia Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/fsmap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c index dbccf46f17709..37347ba868b70 100644 --- a/fs/ext4/fsmap.c +++ b/fs/ext4/fsmap.c @@ -108,6 +108,9 @@ static int ext4_getfsmap_helper(struct super_block *sb, /* Are we just counting mappings? */ if (info->gfi_head->fmh_count == 0) { + if (info->gfi_head->fmh_entries == UINT_MAX) + return EXT4_QUERY_RANGE_ABORT; + if (rec_fsblk > info->gfi_next_fsblk) info->gfi_head->fmh_entries++; -- 2.25.1