All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Casey Chen <cachen@purestorage.com>
Cc: linux-nvme@lists.infradead.org, yzhong@purestorage.com,
	ashishk@purestorage.com
Subject: Re: [PATCH 1/2] nvme-pci: Fix multiple races in nvme_setup_io_queues()
Date: Wed, 23 Jun 2021 07:50:07 -0700	[thread overview]
Message-ID: <20210623145007.GC2360166@dhcp-10-100-145-180.wdc.com> (raw)
In-Reply-To: <9681def7-a751-f4d8-8a92-c5bee027a97a@purestorage.com>

On Tue, Jun 22, 2021 at 09:14:21PM -0700, Casey Chen wrote:
> +/*
> + * Try getting shutdown_lock while setting up IO queues.
> + * Caller remember to unlock if success.
> + */
> +static int nvme_setup_io_queues_trylock(struct nvme_dev *dev)
> +{
> +       /*
> +       * Lock is being held by nvme_dev_disable(), fail early.
> +       */
> +       if (!mutex_trylock(&dev->shutdown_lock))
> +               return -ENODEV;
> +
> +       /*
> +       * Controller is in wrong state, fail early.
> +        */
> +       if (dev->ctrl.state != NVME_CTRL_CONNECTING) {
> +               mutex_unlock(&dev->shutdown_lock);
> +               return -ENODEV;
> +       }
> +
> +       return 0;
> +}
> +

Yes, thank you, this is aligned with what I suggested.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2021-06-23 14:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22  0:27 rr: nvme-pci: fix races in nvme_setup_io_queues() and UAF introduced by nvme_dev_remove_admin() Casey Chen
2021-06-22  0:27 ` [PATCH 1/2] nvme-pci: Fix multiple races in nvme_setup_io_queues() Casey Chen
2021-06-22 15:06   ` Keith Busch
2021-06-23  0:59     ` Casey Chen
2021-06-23  1:53       ` Keith Busch
2021-06-23  4:00         ` Casey Chen
2021-06-23  4:14           ` Casey Chen
2021-06-23 14:50             ` Keith Busch [this message]
2021-06-22  0:27 ` [PATCH 2/2] nvme-pci: Fix UAF introduced by nvme_dev_remove_admin() Casey Chen
2021-06-22 19:16   ` Keith Busch
2021-06-24 17:31 [PATCH 0/2] rr: nvme-pci: fix races and UAF Casey Chen
2021-06-24 17:31 ` [PATCH 1/2] nvme-pci: Fix multiple races in nvme_setup_io_queues() Casey Chen
2021-07-06 18:37   ` Keith Busch

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=20210623145007.GC2360166@dhcp-10-100-145-180.wdc.com \
    --to=kbusch@kernel.org \
    --cc=ashishk@purestorage.com \
    --cc=cachen@purestorage.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=yzhong@purestorage.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.