Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3869282ybz; Mon, 4 May 2020 11:12:19 -0700 (PDT) X-Google-Smtp-Source: APiQypKd02d4Uvic/4iwVIStrOHw/x7k2sgQjjSHo3OrVjc0u9T4m+SBRPAc/I9D99wed+5gRvao X-Received: by 2002:aa7:dd14:: with SMTP id i20mr15291121edv.225.1588615939722; Mon, 04 May 2020 11:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588615939; cv=none; d=google.com; s=arc-20160816; b=pLsyv+OiSjK+I250iDGzfB8B1Zn6b7q+5cEG2xnpdHJZQszb2XnyeBUqgs236qSn5z QKTbXGAGEf0p/X35ofRw3dvOnqgULosulzMTlQMoQozBOwM9upA3KJCB5GJeU72dOeGy n47yM+BTkAy+ucXviTDe5D4uQqm5XRpL6EIBylS3qN1uAQzXgIOE7qv9L2qxlBQ1CMNl vdYZxiJAwPCVfbAEdGFHU2hjRl4MD8uJaVPULq9uM559gRaXfFUF779w4urqOatBjkiu /QUNyAKeGcr8UzN62YUh/QCV+/3SusfdiIxcfspeAVoEcieM0x10Kml5w5s7/PUgmqoF DOGA== 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=d9f9M5hbY+dM2ra/y6ON7zqFPKZqIdwAK/B7z8xmvkA=; b=VQ5UXEieqoiG1p9YjCY/7cjrAZ0WR7VZGk04nFXVq28qvM7liwYSqp5N+c+AXv0SLU 6w50iFfFoBJ+HiOVvMhqClY3Vw6cpMkJH1BQSq0JKXUcA0bSuzbI/Qz5hDcR83ocrCDs FV/Os+MP7vdw5vQ9UjvN2X5idAABSM6HUz8DF37WaJF/X6ofCz+7GKJNmpJ04VHfu3J4 MGMD5UY5o5c/RTJ32+ARSTl1Jda4ZIPbxWwXkVLUwZpcvhINNmQlwrWWVN73s+0x2vTP ZuVfI0t8DhOLZAZRhGdwmET8k0pNf04HrVKa5XPLYUMuuOFasTOrUV1sru0zaNfsjT/6 y5Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dDEJQTYh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si7087918ejs.64.2020.05.04.11.11.55; Mon, 04 May 2020 11:12:19 -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=dDEJQTYh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732243AbgEDSIw (ORCPT + 99 others); Mon, 4 May 2020 14:08:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:38360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732154AbgEDSH3 (ORCPT ); Mon, 4 May 2020 14:07:29 -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 11DDF2087E; Mon, 4 May 2020 18:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588615649; bh=0iRX5pdG6hLfO5oiZwm3feE0J+0QYE/p8vgpjkEUCww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dDEJQTYh+odTOwFQuXafEJgzit0DXAcpaHOqx4kTQnhNasg68IxY4mZA46INrs7jW ooTVZYeTMKYnsJIFVZXOsnW/eRATRrEw0VDOvEyhzU30O3uQfevSLsXogVMLHQkaEg BjFI0sZ/cL4miCpB9L2+b1jnyNgCWqMMq/TiOSXs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niklas Cassel , Christoph Hellwig Subject: [PATCH 5.6 66/73] nvme: prevent double free in nvme_alloc_ns() error handling Date: Mon, 4 May 2020 19:58:09 +0200 Message-Id: <20200504165510.184799022@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200504165501.781878940@linuxfoundation.org> References: <20200504165501.781878940@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: Niklas Cassel commit 132be62387c7a72a38872676c18b0dfae264adb8 upstream. When jumping to the out_put_disk label, we will call put_disk(), which will trigger a call to disk_release(), which calls blk_put_queue(). Later in the cleanup code, we do blk_cleanup_queue(), which will also call blk_put_queue(). Putting the queue twice is incorrect, and will generate a KASAN splat. Set the disk->queue pointer to NULL, before calling put_disk(), so that the first call to blk_put_queue() will not free the queue. The second call to blk_put_queue() uses another pointer to the same queue, so this call will still free the queue. Fixes: 85136c010285 ("lightnvm: simplify geometry enumeration") Signed-off-by: Niklas Cassel Signed-off-by: Christoph Hellwig Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/core.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3580,6 +3580,8 @@ static int nvme_alloc_ns(struct nvme_ctr return 0; out_put_disk: + /* prevent double queue cleanup */ + ns->disk->queue = NULL; put_disk(ns->disk); out_unlink_ns: mutex_lock(&ctrl->subsys->lock);