All of lore.kernel.org
 help / color / mirror / Atom feed
From: sagi@grimberg.me (Sagi Grimberg)
Subject: [Suspected-Phishing]Re: [PATCH 2/7] nvme-rdma: fix possible free non-allocated async event buffer
Date: Sun, 24 Jun 2018 19:00:10 +0300	[thread overview]
Message-ID: <af45efbc-f037-241b-9fc2-e96e0ff157a8@grimberg.me> (raw)
In-Reply-To: <91bc7b1a-6fb1-e1e0-3437-dc8e46cc6d58@mellanox.com>


> this fix still doesn't fix the issue that V1 from Israel did.

This fixes the issue that was reported (nvme_rdma_free_queue frees
unallocated async_event_sqe).

> we still can call nvme_rdma_destroy_admin_queue few times (as I 
> mentioned nvme_rdma_free_queue is safe by NVME_RDMA_Q_ALLOCATED bit but 
> nvme_rdma_destroy_admin_queue isn't).

ugh... yes this is not enough to avoid the double free if
reset/reconnect calls nvme_delete_ctrl.

> I added this check but I think this is not enough since things can run 
> concurrently (I still need to make some testing and review):

The destroy routines are serialized by the work flush/cancel so it
should be fine.

> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
> index 5194568..e99ff80 100644
> --- a/drivers/nvme/host/rdma.c
> +++ b/drivers/nvme/host/rdma.c
> @@ -168,8 +168,11 @@ static inline size_t 
> nvme_rdma_inline_data_size(struct nvme_rdma_queue *queue)
>  ?static void nvme_rdma_free_qe(struct ib_device *ibdev, struct 
> nvme_rdma_qe *qe,
>  ??????????????? size_t capsule_size, enum dma_data_direction dir)
>  ?{
> -?????? ib_dma_unmap_single(ibdev, qe->dma, capsule_size, dir);
> -?????? kfree(qe->data);
> +?????? if (qe->data) {
> +?????????????? ib_dma_unmap_single(ibdev, qe->dma, capsule_size, dir);
> +?????????????? kfree(qe->data);
> +?????????????? qe->data = NULL;
> +?????? }
>  ?}

I'd prefer to keep this check to the async event buffer:
--
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 9f5fc7b7fd7f..69c9b7bc0d5b 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -732,8 +732,11 @@ static void nvme_rdma_destroy_admin_queue(struct 
nvme_rdma_ctrl *ctrl,
                 blk_cleanup_queue(ctrl->ctrl.admin_q);
                 nvme_rdma_free_tagset(&ctrl->ctrl, 
ctrl->ctrl.admin_tagset);
         }
-       nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
-               sizeof(struct nvme_command), DMA_TO_DEVICE);
+       if (ctrl->async_event_sqe.data) {
+               nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
+                       sizeof(struct nvme_command), DMA_TO_DEVICE);
+                       ctrl->async_event_sqe.data = NULL;
+       }
         nvme_rdma_free_queue(&ctrl->queues[0]);
  }
--

Does this make the issue go away Max?

  reply	other threads:[~2018-06-24 16:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 12:34 [PATCH 0/7] few nvme-rdma fixes for 4.18 Sagi Grimberg
2018-06-19 12:34 ` [PATCH 1/7] nvme-rdma: fix possible double free condition when failing to create a controller Sagi Grimberg
2018-06-20  9:06   ` Max Gurtovoy
2018-06-20 10:41     ` Sagi Grimberg
2018-06-20 12:29       ` Christoph Hellwig
2018-06-19 12:34 ` [PATCH 2/7] nvme-rdma: fix possible free non-allocated async event buffer Sagi Grimberg
2018-06-20  8:31   ` Christoph Hellwig
2018-06-20 12:02     ` Max Gurtovoy
2018-06-24 10:40       ` [Suspected-Phishing]Re: " Max Gurtovoy
2018-06-24 16:00         ` Sagi Grimberg [this message]
2018-06-24 16:19           ` Max Gurtovoy
2018-06-19 12:34 ` [PATCH 3/7] nvme-rdma: Fix command completion race at error recovery Sagi Grimberg
2018-06-19 12:34 ` [PATCH 4/7] nvme-rdma: unquiesce queues when deleting the controller Sagi Grimberg
2018-06-21  9:57   ` Max Gurtovoy
2018-06-24 16:07     ` Sagi Grimberg
2018-06-19 12:34 ` [PATCH 5/7] nvme-rdma: don't override opts->queue_size Sagi Grimberg
2018-06-19 16:56   ` Daniel Verkamp
2018-06-19 12:34 ` [PATCH 6/7] nvme-rdma: centralize controller setup sequence Sagi Grimberg
2018-06-19 12:34 ` [PATCH 7/7] nvme-rdma: centralize admin/io queue teardown sequence Sagi Grimberg
2018-06-20  8:40 ` [PATCH 0/7] few nvme-rdma fixes for 4.18 Christoph Hellwig
2018-06-20  8:40   ` Sagi Grimberg
2018-06-20  8:52     ` Christoph Hellwig
2018-06-20  8:53       ` Sagi Grimberg
2018-06-20  9:05         ` Christoph Hellwig
2018-06-20  9:08           ` 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=af45efbc-f037-241b-9fc2-e96e0ff157a8@grimberg.me \
    --to=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 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.