linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tong Zhang <ztong0001@gmail.com>
To: Keith Busch <kbusch@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
	axboe@fb.com, Christoph Hellwig <hch@lst.de>,
	sagi@grimberg.me
Subject: Re: [PATCH] nvme-pci: cancel nvme device request before disabling
Date: Fri, 14 Aug 2020 11:37:20 -0400	[thread overview]
Message-ID: <CAA5qM4CctYiBe766-OnxAPHJWByyOo1rE7FzW-75ZcOib6niCA@mail.gmail.com> (raw)
In-Reply-To: <20200814150433.GA3498391@dhcp-10-100-145-180.wdl.wdc.com>

Hi Keith,

On Fri, Aug 14, 2020 at 11:04 AM Keith Busch <kbusch@kernel.org> wrote:
>
> On Fri, Aug 14, 2020 at 03:14:31AM -0400, Tong Zhang wrote:
> > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> > index ba725ae47305..c4f1ce0ee1e3 100644
> > --- a/drivers/nvme/host/pci.c
> > +++ b/drivers/nvme/host/pci.c
> > @@ -1249,8 +1249,8 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
> >               dev_warn_ratelimited(dev->ctrl.device,
> >                        "I/O %d QID %d timeout, disable controller\n",
> >                        req->tag, nvmeq->qid);
> > -             nvme_dev_disable(dev, true);
> >               nvme_req(req)->flags |= NVME_REQ_CANCELLED;
> > +             nvme_dev_disable(dev, true);
> >               return BLK_EH_DONE;
>
> Shouldn't this flag have been set in nvme_cancel_request()?

nvme_cancel_request() is not setting this flag to cancelled and this is causing
__nvme_submit_sync_cmd() to return a positive number and eventually
this will allow nvme_init_identify() proceed with a timeout error where the
problematic nvme device has already been disabled by nvme_dev_disable(dev,true).
The reset of the logic in nvme_init_identify() is not going to check
those already
released resources. -- in fact this is UAF --

> like the timeout out command is the only command to have been cancelled
> by this action, nor is it guaranteed that getting here will mean the
> request was in fact cancelled. The controller could still provide a real
> completion.

what would you like to suggest here?

  reply	other threads:[~2020-08-14 15:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-14  7:14 [PATCH] nvme-pci: cancel nvme device request before disabling Tong Zhang
2020-08-14  8:16 ` Christoph Hellwig
2020-08-14 11:53   ` Tong Zhang
2020-08-14 11:46 ` [PATCH v2] " Tong Zhang
2020-08-14 15:04 ` [PATCH] " Keith Busch
2020-08-14 15:37   ` Tong Zhang [this message]
2020-08-14 15:42     ` Keith Busch
2020-08-14 16:11       ` Tong Zhang
2020-08-27 15:01         ` Keith Busch
2020-08-28 12:43           ` Tong Zhang
2020-08-28 14:17           ` [PATCH v2] " Tong Zhang
2020-08-28 15:51             ` Keith Busch
2020-08-28 15:56             ` Sagi Grimberg
2020-08-14 18:00       ` [PATCH] " Sagi Grimberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAA5qM4CctYiBe766-OnxAPHJWByyOo1rE7FzW-75ZcOib6niCA@mail.gmail.com \
    --to=ztong0001@gmail.com \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).