From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:58358 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387825AbeGKNpm (ORCPT ); Wed, 11 Jul 2018 09:45:42 -0400 Date: Wed, 11 Jul 2018 15:41:15 +0200 From: Greg KH To: Simon Veith Cc: stable@vger.kernel.org, David Woodhouse , Amit Shah , Keith Busch Subject: Re: [PATCH 4.9] nvme: validate admin queue before force-start on removal Message-ID: <20180711134115.GA2306@kroah.com> References: <1531315312-19356-1-git-send-email-sveith@amazon.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1531315312-19356-1-git-send-email-sveith@amazon.de> Sender: stable-owner@vger.kernel.org List-ID: On Wed, Jul 11, 2018 at 03:21:52PM +0200, Simon Veith wrote: > Commit 4aae4388165a2611fa4206363ccb243c1622446c ("nvme: fix hang in remove > path"), which was introduced in Linux 4.9.94, changed nvme_kill_queues() > to also forcibly start admin queues in order to avoid getting stuck during > device removal. > > If a device is being removed because it did not respond during device > initialization (e.g., if it is not ready yet at boot time), we will end up > trying to start an admin queue that has not yet been set up at all. This > attempt will lead to a NULL pointer dereference. > > To avoid hitting this bug, we add a sanity check around the invocation of > blk_mq_start_hw_queues() to ensure that the admin queue has actually been > set up already. > > Upstream already has this check in place since commit > 7dd1ab163c17e11473a65b11f7e748db30618ebb ("nvme: validate admin queue > before unquiesce"), and thus 4.14 contains it as well. Linux 4.4 is not > affected by this particular issue since it does not have the force-start > behavior yet. > > Fixes: 4aae4388165a2611fa42 ("nvme: fix hang in remove path") > > Signed-off-by: Simon Veith > Signed-off-by: David Woodhouse > --- > drivers/nvme/host/core.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index c823e93..8a30478 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -2041,8 +2041,10 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl) > > mutex_lock(&ctrl->namespaces_mutex); > > - /* Forcibly start all queues to avoid having stuck requests */ > - blk_mq_start_hw_queues(ctrl->admin_q); > + if (ctrl->admin_q) { > + /* Forcibly start all queues to avoid having stuck requests */ > + blk_mq_start_hw_queues(ctrl->admin_q); > + } > Why have you rewritten commit 7dd1ab163c17 ("nvme: validate admin queue before unquiesce") here? Why not just backport it directly? confused, greg k-h