Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2185883ybm; Thu, 23 May 2019 12:46:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJj6sB9bqMqIJhRU/94B++bw3bIGseeTFPz8G0T3dNI+BQcyFo8Vx4Rj4Gtm5tyghaw/0r X-Received: by 2002:a63:ee0a:: with SMTP id e10mr85945130pgi.28.1558640805193; Thu, 23 May 2019 12:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558640805; cv=none; d=google.com; s=arc-20160816; b=jxtw/YKemLuG2NXaJR7ZTOu45v2BALMwQRqSC50+pzSI3VebP44E+aIqVcM8sI0++/ oHs7nK17CzaQ2jerXsBMQ7ZufJRL9pd5nGZi6zCOO6ueuXBkL+HPwMNEELIERUvNyAfe xJQdFxeqnBI0mjjAGMWmAcw7aITtrg+27FBGHCCiLa31vQtEoAGnKYsV0DtheBIAQt8A a02W+N2nMwR9naDq2wUdi7yLOBvt4L+69qE3uGbF3ujh9v22lnxX2OTl8htFXLWpeCap 1ntKSD83l2HKtZSexCr8lpthYuFV7vJKyKVwwNNMdgr0ea5I/mWHtN8yCc++epTlDR5y VT+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PA1FVkGOEbZgXAmI4EUOUKmB0+iEZHn9Oyg5hsM5i5Q=; b=tiPhhJ01Uwd4qRTb8MpZMtFVhdCnkHrzpMsH/2KobBv+wh0PGLkSKqN24gD8fhP1yJ iuen+ojcGhEMZXcdwrny+w3zAJP1Aw9uFyCNYovB6Z5yW6ovEs+jm4RMzvY2SI7oShdt 3zbBVOiAcrZ6o10DspWs+cq56ppXp6Q8eIAezd4bWm98/5m99XcKpKPMZH1R1rn2A+iF mt5wZHjGW5EUb5P9wo7hPtSMtPxzVrhH3lbqVm76/1n0NSTuRU4Y6ajqjS4UVKHoroIV WYJCoD70qynzFd7e8F/NgENRsFWnyOctWi9uFtK76JlfEg++JPQ5aFNx7M49OMd592UN 2xRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i9blYKXa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si636289plr.220.2019.05.23.12.46.30; Thu, 23 May 2019 12:46:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i9blYKXa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389440AbfEWTRd (ORCPT + 99 others); Thu, 23 May 2019 15:17:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:52698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389422AbfEWTRb (ORCPT ); Thu, 23 May 2019 15:17:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 D0200205ED; Thu, 23 May 2019 19:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558639051; bh=2ptE7vIvQyhsyXR24RemViMRC03B+p8ztYdpEcbI6Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i9blYKXaU4yAoXm83nllufu3qpCZR/p/wBlH4AUKvNEqEWY1ZZgCa2brRj2wwiPTV I75uQR0lsya6aSth75oxe3B1QhcFtnWmxXe+YxsQ/xM72Xw9Eis3yeItlEdgZgHQSe gqI3qM3VAy97sHppQwW61gxPoxqP6rjSc4Or0UfI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Damien Le Moal , Shaun Tancheff , Mike Snitzer Subject: [PATCH 4.19 078/114] dm zoned: Fix zone report handling Date: Thu, 23 May 2019 21:06:17 +0200 Message-Id: <20190523181738.800421591@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181731.372074275@linuxfoundation.org> References: <20190523181731.372074275@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Damien Le Moal commit 7aedf75ff740a98f3683439449cd91c8662d03b2 upstream. The function blkdev_report_zones() returns success even if no zone information is reported (empty report). Empty zone reports can only happen if the report start sector passed exceeds the device capacity. The conditions for this to happen are either a bug in the caller code, or, a change in the device that forced the low level driver to change the device capacity to a value that is lower than the report start sector. This situation includes a failed disk revalidation resulting in the disk capacity being changed to 0. If this change happens while dm-zoned is in its initialization phase executing dmz_init_zones(), this function may enter an infinite loop and hang the system. To avoid this, add a check to disallow empty zone reports and bail out early. Also fix the function dmz_update_zone() to make sure that the report for the requested zone was correctly obtained. Fixes: 3b1a94c88b79 ("dm zoned: drive-managed zoned block device target") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal Reviewed-by: Shaun Tancheff Signed-off-by: Damien Le Moal Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-zoned-metadata.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/md/dm-zoned-metadata.c +++ b/drivers/md/dm-zoned-metadata.c @@ -1169,6 +1169,9 @@ static int dmz_init_zones(struct dmz_met goto out; } + if (!nr_blkz) + break; + /* Process report */ for (i = 0; i < nr_blkz; i++) { ret = dmz_init_zone(zmd, zone, &blkz[i]); @@ -1204,6 +1207,8 @@ static int dmz_update_zone(struct dmz_me /* Get zone information from disk */ ret = blkdev_report_zones(zmd->dev->bdev, dmz_start_sect(zmd, zone), &blkz, &nr_blkz, GFP_NOIO); + if (!nr_blkz) + ret = -EIO; if (ret) { dmz_dev_err(zmd->dev, "Get zone %u report failed", dmz_id(zmd, zone));