Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1248504pxa; Thu, 20 Aug 2020 06:43:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKKqDhacEazxWARrq95m6uqi15aE2G1Dy5gFkx+bnPPUxfe8VwwsvtYeWn+9Gbn57l4h1Z X-Received: by 2002:a17:907:42cc:: with SMTP id nz20mr3388880ejb.429.1597931028096; Thu, 20 Aug 2020 06:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597931028; cv=none; d=google.com; s=arc-20160816; b=FqCIStF0UCiZTpcbzisGafi8kGTPHyH6YIVo5OJ6MKzreBQztxDmfYC950EmF5Xi2j QyJBE9zxQQtv5mGS+Fo3Es+4J5aFDYL+OJ5LX2ycuUYMLTz8Lv50BahI0eSMYlCozFip oJqbXHdValAOqW3X/jGwn8iiqhZ02aDD24Wh/GLVP39sNJtD1ro0bT0YsNXSK/C3ITgb y/UqRoyAeQCnRuG56MpwxWkL20pSur5ooCjNCdK0IL8Btywq4B1zP2t5VtoF7Gk7QvzP aNTrIbMSiZLBbz9LCnjOcDez4STZ3D1CZrAjQL/VAnHeWbhwEPIt4cgRDZ+2bUTSL6eB 3hvw== 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=Nii8FNyPkWESFwTcZyUFu+OKXETryGaRClyZ+5ne1GA=; b=0+cICxXSOh5Mv0bz+Yy9MOQlrmwTksXl2OjcmphphD6+OMTMhDnp4q8XAZHZeDVuXu wudO1HfQAWL2Z8BKqKEYyyyFvaXQXvOo3w9rSP1psL/O9fj4vtvyVNx1yY5rWRPo377S KvAw09fy0AZG9sLOek0pG7My497yINubfrX77dUuQBJLrCxS7IG8xz4VLWQ1PTfqU8OF 0yJgPfKU3b/hYt9IJeSXJQ8DvWHXP4gxkwCievodciI14SHDqaAaJSdNDLBC6WmJtmnq Y7u9V/odt4pY0xPadPrupQWvDAiX1bk3L/FRmWnldhQmVKOG/RMs6ADq32Iwjjqw8WKD l0sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gdJD2B0v; 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 b31si1329005edf.456.2020.08.20.06.43.22; Thu, 20 Aug 2020 06:43:48 -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=gdJD2B0v; 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 S1729992AbgHTNmV (ORCPT + 99 others); Thu, 20 Aug 2020 09:42:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:38982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727012AbgHTJ3c (ORCPT ); Thu, 20 Aug 2020 05:29:32 -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 2E32622CB2; Thu, 20 Aug 2020 09:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915771; bh=rYL2IwAIcAFoDXZRpBmPjSQUP7VADmZhoj4Za1W7tt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gdJD2B0vtEqDxXJPdSod66qt9gRMofWTdnTVHuQI6Y8rV6ODYQFrQmLI/D9mkr69z cRumilPWCXjqWnwWIW8W4BTTcB9DKUVVbG+pUVCt2CYSrlYknUFbuz6yN61iFWlAJM ydOmgy7HMcnjIQIHwKu0wC0eyxiI9UHQI964vohY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Damien Le Moal , Mike Snitzer Subject: [PATCH 5.8 099/232] dm: dont call report zones for more than the user requested Date: Thu, 20 Aug 2020 11:19:10 +0200 Message-Id: <20200820091617.626527301@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@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: Johannes Thumshirn commit a9cb9f4148ef6bb8fabbdaa85c42b2171fbd5a0d upstream. Don't call report zones for more zones than the user actually requested, otherwise this can lead to out-of-bounds accesses in the callback functions. Such a situation can happen if the target's ->report_zones() callback function returns 0 because we've reached the end of the target and then restart the report zones on the second target. We're again calling into ->report_zones() and ultimately into the user supplied callback function but when we're not subtracting the number of zones already processed this may lead to out-of-bounds accesses in the user callbacks. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien Le Moal Fixes: d41003513e61 ("block: rework zone reporting") Cc: stable@vger.kernel.org # v5.5+ Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -504,7 +504,8 @@ static int dm_blk_report_zones(struct ge } args.tgt = tgt; - ret = tgt->type->report_zones(tgt, &args, nr_zones); + ret = tgt->type->report_zones(tgt, &args, + nr_zones - args.zone_idx); if (ret < 0) goto out; } while (args.zone_idx < nr_zones &&