linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagi@grimberg.me>
To: linux-nvme@lists.infradead.org, Christoph Hellwig <hch@lst.de>,
	Keith Busch <kbusch@kernel.org>
Cc: Chris Leech <cleech@redhat.com>
Subject: [PATCH v2 2/3] nvme-tcp: fix possible use-after-free in transport error_recovery work
Date: Tue,  1 Feb 2022 14:54:20 +0200	[thread overview]
Message-ID: <20220201125421.177942-3-sagi@grimberg.me> (raw)
In-Reply-To: <20220201125421.177942-1-sagi@grimberg.me>

While nvme_tcp_submit_async_event_work is checking the ctrl and queue
state before preparing the AER command and scheduling io_work, in order
to fully prevent a race where this check is not reliable the error
recovery work must flush async_event_work before continuing to destroy
the admin queue after setting the ctrl state to RESETTING such that
there is no race .submit_async_event and the error recovery handler
itself changing the ctrl state.

Tested-by: Chris Leech <cleech@redhat.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 drivers/nvme/host/tcp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 4ceb28675fdf..01e24b5703db 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -2096,6 +2096,7 @@ static void nvme_tcp_error_recovery_work(struct work_struct *work)
 	struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl;
 
 	nvme_stop_keep_alive(ctrl);
+	flush_work(&ctrl->async_event_work);
 	nvme_tcp_teardown_io_queues(ctrl, false);
 	/* unquiesce to fail fast pending requests */
 	nvme_start_queues(ctrl);
-- 
2.30.2



  parent reply	other threads:[~2022-02-01 12:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 12:54 [PATCH v2 0/3] nvme-[tcp|rdma] fix for possible use-after-free Sagi Grimberg
2022-02-01 12:54 ` [PATCH v2 1/3] nvme: fix a possible use-after-free in controller reset during load Sagi Grimberg
2022-02-03 14:43   ` Max Gurtovoy
2022-02-03 15:03     ` Sagi Grimberg
2022-02-03 15:47       ` Max Gurtovoy
2022-02-04 12:20   ` Hannes Reinecke
2022-02-01 12:54 ` Sagi Grimberg [this message]
2022-02-04 12:20   ` [PATCH v2 2/3] nvme-tcp: fix possible use-after-free in transport error_recovery work Hannes Reinecke
2022-02-01 12:54 ` [PATCH v2 3/3] nvme-rdma: " Sagi Grimberg
2022-02-04 12:21   ` Hannes Reinecke

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=20220201125421.177942-3-sagi@grimberg.me \
    --to=sagi@grimberg.me \
    --cc=cleech@redhat.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    /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).