Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5849203ybn; Sun, 29 Sep 2019 07:03:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNWpy/kDHFSZS3wl+vKIi4Ea9CjrE/b3QnxpE8QdpJKq4jhgp+BcALjRNC1xCXLH5Cx5oJ X-Received: by 2002:aa7:c743:: with SMTP id c3mr15004167eds.241.1569765785795; Sun, 29 Sep 2019 07:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569765785; cv=none; d=google.com; s=arc-20160816; b=gMPI85rNDt+SbzrsvYHyAOtrK4fBgDiDfC3+DmPpsSJgfXXRXDpmybIKC5bgaM+kG8 jeHvg1balZztWNOsCIZFgGfjyLBptpIJzuUBaVgMjE02QYc54yXz1tAirj+nNHzScOH7 7SWgHuoXnp/i46Xt+SrYbmW7PKsntWAs2qgKvG/3VPVwhmt8Hmr4Aa+FbBLKV6YhvvzP W6MRLsuESMmIiDTjFZgFYIZVJf2DyBLDqZC/nU2Lr5WfiawKbiY4AeJZJ9WH8OSswAOt XAQ/w1Nc9iLfbCYP1daSGtZ0Cs0y24XVJweFgWlFtAxeHs8LrAqgUD4EwBVoxWbcBvev GZFw== 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=eLQDFXJ4q+ZgknJbMUQ6KzJ6l7gyNLThdUtJHeXA/uc=; b=nJoQfHbKYpMMF3AgojFUUruIMTzfl28bkQbULLleTaeAN8Q7eTM4D49f0MGFjmnBoj bf/J48mKMXejiMGZ6Q03ISBGo8+BMgMBGLOAWykNKrQkuHmjVbAfUUfZ2u47spAJ8bfM Lvy8p4CXRosv8HDSFLWdXyCWLLCjdom9+IgP9hVL4jGfmpz4jPFg6L6ghRqFtfCvsHZ9 KhWSUw3Ajnam20l/z6QTAh/CLAbYZNp7ihqmTMaYuEhNTSilIYeaXE1g+yxAfzQo/jr3 S2mS5XMAsCOFyhI25E/NCkIrJDYCy8DWLvr+zA7Eu4gogwBw18FSJ+UnSgaa4kyHab/k y1Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MXJ3nnIE; 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 g21si5168436edq.289.2019.09.29.07.02.41; Sun, 29 Sep 2019 07:03:05 -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=MXJ3nnIE; 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 S1729442AbfI2OBf (ORCPT + 99 others); Sun, 29 Sep 2019 10:01:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:43800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730046AbfI2OBc (ORCPT ); Sun, 29 Sep 2019 10:01: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 0DAEF2082F; Sun, 29 Sep 2019 14:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765691; bh=gsJ9MevCMoJdi7WNJxdX6xfWTX7QyQwP9gCc+FHWx0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MXJ3nnIEMTFYOf9IMpNRgaOk0OZGZXuNWG4VNp+fEZEGwBGt0PJfVwB2hhg+VrM/X bqXc9RsrGWCc2Dwck0lMH/bPteBTIIuy0NMD9ClnYfcxEwOcLom2zzNlq5nMAAOGUg aAIN2GT5C0kBwa57BX8TMtMoAmGkjDsqx7v6k0NE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Damien Le Moal , Mike Snitzer , Sasha Levin Subject: [PATCH 5.2 31/45] dm zoned: fix invalid memory access Date: Sun, 29 Sep 2019 15:55:59 +0200 Message-Id: <20190929135032.102259596@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135024.387033930@linuxfoundation.org> References: <20190929135024.387033930@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: Mikulas Patocka [ Upstream commit 0c8e9c2d668278652af028c3cc068c65f66342f4 ] Commit 75d66ffb48efb30f2dd42f041ba8b39c5b2bd115 ("dm zoned: properly handle backing device failure") triggers a coverity warning: *** CID 1452808: Memory - illegal accesses (USE_AFTER_FREE) /drivers/md/dm-zoned-target.c: 137 in dmz_submit_bio() 131 clone->bi_private = bioctx; 132 133 bio_advance(bio, clone->bi_iter.bi_size); 134 135 refcount_inc(&bioctx->ref); 136 generic_make_request(clone); >>> CID 1452808: Memory - illegal accesses (USE_AFTER_FREE) >>> Dereferencing freed pointer "clone". 137 if (clone->bi_status == BLK_STS_IOERR) 138 return -EIO; 139 140 if (bio_op(bio) == REQ_OP_WRITE && dmz_is_seq(zone)) 141 zone->wp_block += nr_blocks; 142 The "clone" bio may be processed and freed before the check "clone->bi_status == BLK_STS_IOERR" - so this check can access invalid memory. Fixes: 75d66ffb48efb3 ("dm zoned: properly handle backing device failure") Cc: stable@vger.kernel.org Signed-off-by: Mikulas Patocka Reviewed-by: Damien Le Moal Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin --- drivers/md/dm-zoned-target.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c index ff3fd011796ed..3334f5865de77 100644 --- a/drivers/md/dm-zoned-target.c +++ b/drivers/md/dm-zoned-target.c @@ -133,8 +133,6 @@ static int dmz_submit_bio(struct dmz_target *dmz, struct dm_zone *zone, refcount_inc(&bioctx->ref); generic_make_request(clone); - if (clone->bi_status == BLK_STS_IOERR) - return -EIO; if (bio_op(bio) == REQ_OP_WRITE && dmz_is_seq(zone)) zone->wp_block += nr_blocks; -- 2.20.1