All of lore.kernel.org
 help / color / mirror / Atom feed
From: israelr@mellanox.com (Israel Rukshin)
Subject: [PATCH 1/2 v3] nvme-rdma: Fix race between queue timeout and error recovery
Date: Wed, 11 Apr 2018 16:07:03 +0000	[thread overview]
Message-ID: <1523462824-25643-2-git-send-email-israelr@mellanox.com> (raw)
In-Reply-To: <1523462824-25643-1-git-send-email-israelr@mellanox.com>

When returning BLK_EH_HANDLED from nvme_rdma_timeout() the block layer
complete the request.
Returning BLK_EH_RESET_TIMER is safe because those requests will be completed
later by nvme abort mechanism.

Completing the requests in the timeout handler was done while
the rdma queues were active.
When completing the request we return its mr to the mr pool (set mr to NULL)
and also unmap its data.
This leads to a NULL deref of the mr if we get a rdma completion of a
completed request.
This also lead to unmapping the request data before it is really safe.

Signed-off-by: Israel Rukshin <israelr at mellanox.com>
Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
---
 drivers/nvme/host/rdma.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 758537e..c1abfc8 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1595,10 +1595,7 @@ static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id,
 	/* queue error recovery */
 	nvme_rdma_error_recovery(req->queue->ctrl);
 
-	/* fail with DNR on cmd timeout */
-	nvme_req(rq)->status = NVME_SC_ABORT_REQ | NVME_SC_DNR;
-
-	return BLK_EH_HANDLED;
+	return BLK_EH_RESET_TIMER;
 }
 
 /*
-- 
1.8.3.1

  reply	other threads:[~2018-04-11 16:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-11 16:07 [PATCH 0/2 v3] Fix nvme-rdma timeout flow Israel Rukshin
2018-04-11 16:07 ` Israel Rukshin [this message]
2018-04-12 13:36   ` [PATCH 1/2 v3] nvme-rdma: Fix race between queue timeout and error recovery Christoph Hellwig
2018-04-11 16:07 ` [PATCH 2/2 v3] nvme-rdma: Fix command completion race at " Israel Rukshin
2018-04-12 13:37   ` Christoph Hellwig
2018-04-15 13:50     ` Max Gurtovoy

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=1523462824-25643-2-git-send-email-israelr@mellanox.com \
    --to=israelr@mellanox.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.