All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 4.14-rc fix-regression] nvme-rdma: Fix possible double free in reconnect flow
@ 2017-10-19 13:00 Sagi Grimberg
  2017-10-19 13:32 ` Johannes Thumshirn
  2017-10-19 15:07 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Sagi Grimberg @ 2017-10-19 13:00 UTC (permalink / raw)


The fact that we free the async event buffer in
nvme_rdma_destroy_admin_queue can cause us to free it
more than once because this happens in every reconnect
attempt since commit 31fdf1840170. we rely on the queue
state flags DELETING to avoid this for other resources.

A more complete fix is to not destroy the admin/io queues
unconditionally on every reconnect attempt, but its a bit
more extensive and will go in the next release.

Fixes: 31fdf1840170 ("nvme-rdma: reuse configure/destroy_admin_queue")
Reported-by: Yi Zhang <yi.zhang at redhat.com>
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
 drivers/nvme/host/rdma.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 92a03ff5fb4d..ec22da478ba3 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -571,6 +571,11 @@ static void nvme_rdma_free_queue(struct nvme_rdma_queue *queue)
 	if (test_and_set_bit(NVME_RDMA_Q_DELETING, &queue->flags))
 		return;
 
+	if(nvme_rdma_queue_idx(queue) == 0)
+		nvme_rdma_free_qe(queue->device->dev,
+			&queue->ctrl->async_event_sqe,
+			sizeof(struct nvme_command), DMA_TO_DEVICE);
+
 	nvme_rdma_destroy_queue_ib(queue);
 	rdma_destroy_id(queue->cm_id);
 }
@@ -739,8 +744,6 @@ static struct blk_mq_tag_set *nvme_rdma_alloc_tagset(struct nvme_ctrl *nctrl,
 static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl,
 		bool remove)
 {
-	nvme_rdma_free_qe(ctrl->queues[0].device->dev, &ctrl->async_event_sqe,
-			sizeof(struct nvme_command), DMA_TO_DEVICE);
 	nvme_rdma_stop_queue(&ctrl->queues[0]);
 	if (remove) {
 		blk_cleanup_queue(ctrl->ctrl.admin_q);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 4.14-rc fix-regression] nvme-rdma: Fix possible double free in reconnect flow
  2017-10-19 13:00 [PATCH v2 4.14-rc fix-regression] nvme-rdma: Fix possible double free in reconnect flow Sagi Grimberg
@ 2017-10-19 13:32 ` Johannes Thumshirn
  2017-10-19 15:07 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2017-10-19 13:32 UTC (permalink / raw)


Thanks a lot,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 4.14-rc fix-regression] nvme-rdma: Fix possible double free in reconnect flow
  2017-10-19 13:00 [PATCH v2 4.14-rc fix-regression] nvme-rdma: Fix possible double free in reconnect flow Sagi Grimberg
  2017-10-19 13:32 ` Johannes Thumshirn
@ 2017-10-19 15:07 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2017-10-19 15:07 UTC (permalink / raw)


Applied to nvme-4.14 after fixing this:

> +	if(nvme_rdma_queue_idx(queue) == 0)

whitespace issue and adding some curly braces.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-19 15:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-19 13:00 [PATCH v2 4.14-rc fix-regression] nvme-rdma: Fix possible double free in reconnect flow Sagi Grimberg
2017-10-19 13:32 ` Johannes Thumshirn
2017-10-19 15:07 ` Christoph Hellwig

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.