* [PATCH] RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence
@ 2020-01-15 20:20 Jason Gunthorpe
2020-01-16 8:51 ` Gal Pressman
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2020-01-15 20:20 UTC (permalink / raw)
To: linux-rdma, Michal Kalderon, Gal Pressman
The set of entry->driver_removed is missing locking, protect it with
xa_lock() which is held by the only reader.
Otherwise readers may continue to see driver_removed = false after
rdma_user_mmap_entry_remove() returns and may continue to try and
establish new mmaps.
Fixes: 3411f9f01b76 ("RDMA/core: Create mmap database and cookie helper functions")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
drivers/infiniband/core/ib_core_uverbs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/infiniband/core/ib_core_uverbs.c b/drivers/infiniband/core/ib_core_uverbs.c
index b7cb59844ece45..b51bd7087a881f 100644
--- a/drivers/infiniband/core/ib_core_uverbs.c
+++ b/drivers/infiniband/core/ib_core_uverbs.c
@@ -232,7 +232,9 @@ void rdma_user_mmap_entry_remove(struct rdma_user_mmap_entry *entry)
if (!entry)
return;
+ xa_lock(&entry->ucontext->mmap_xa);
entry->driver_removed = true;
+ xa_unlock(&entry->ucontext->mmap_xa);
kref_put(&entry->ref, rdma_user_mmap_entry_free);
}
EXPORT_SYMBOL(rdma_user_mmap_entry_remove);
--
2.24.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence
2020-01-15 20:20 [PATCH] RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence Jason Gunthorpe
@ 2020-01-16 8:51 ` Gal Pressman
2020-01-16 13:05 ` Jason Gunthorpe
2020-01-20 11:07 ` Michal Kalderon
2020-01-25 18:52 ` Jason
2 siblings, 1 reply; 5+ messages in thread
From: Gal Pressman @ 2020-01-16 8:51 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: linux-rdma, Michal Kalderon
On 15/01/2020 22:20, Jason Gunthorpe wrote:
> The set of entry->driver_removed is missing locking, protect it with
> xa_lock() which is held by the only reader.
>
> Otherwise readers may continue to see driver_removed = false after
> rdma_user_mmap_entry_remove() returns and may continue to try and
> establish new mmaps.
That's kind of an inherent race regardless, isn't it?
LGTM,
Reviewed-by: Gal Pressman <galpress@amazon.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence
2020-01-16 8:51 ` Gal Pressman
@ 2020-01-16 13:05 ` Jason Gunthorpe
0 siblings, 0 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2020-01-16 13:05 UTC (permalink / raw)
To: Gal Pressman; +Cc: linux-rdma, Michal Kalderon
On Thu, Jan 16, 2020 at 10:51:52AM +0200, Gal Pressman wrote:
> On 15/01/2020 22:20, Jason Gunthorpe wrote:
> > The set of entry->driver_removed is missing locking, protect it with
> > xa_lock() which is held by the only reader.
> >
> > Otherwise readers may continue to see driver_removed = false after
> > rdma_user_mmap_entry_remove() returns and may continue to try and
> > establish new mmaps.
>
> That's kind of an inherent race regardless, isn't it?
How do you mean? Once rdma_user_mmap_entry_remove() returns no new
mmaps can be established, existing mmaps remain. The driver can rely
on this, by, for instance, calling free_page
Jason
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence
2020-01-15 20:20 [PATCH] RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence Jason Gunthorpe
2020-01-16 8:51 ` Gal Pressman
@ 2020-01-20 11:07 ` Michal Kalderon
2020-01-25 18:52 ` Jason
2 siblings, 0 replies; 5+ messages in thread
From: Michal Kalderon @ 2020-01-20 11:07 UTC (permalink / raw)
To: Jason Gunthorpe, linux-rdma, Gal Pressman
> From: linux-rdma-owner@vger.kernel.org <linux-rdma-
> owner@vger.kernel.org> On Behalf Of Jason Gunthorpe
>
> The set of entry->driver_removed is missing locking, protect it with
> xa_lock() which is held by the only reader.
>
> Otherwise readers may continue to see driver_removed = false after
> rdma_user_mmap_entry_remove() returns and may continue to try and
> establish new mmaps.
>
> Fixes: 3411f9f01b76 ("RDMA/core: Create mmap database and cookie helper
> functions")
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> ---
> drivers/infiniband/core/ib_core_uverbs.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/infiniband/core/ib_core_uverbs.c
> b/drivers/infiniband/core/ib_core_uverbs.c
> index b7cb59844ece45..b51bd7087a881f 100644
> --- a/drivers/infiniband/core/ib_core_uverbs.c
> +++ b/drivers/infiniband/core/ib_core_uverbs.c
> @@ -232,7 +232,9 @@ void rdma_user_mmap_entry_remove(struct
> rdma_user_mmap_entry *entry)
> if (!entry)
> return;
>
> + xa_lock(&entry->ucontext->mmap_xa);
> entry->driver_removed = true;
> + xa_unlock(&entry->ucontext->mmap_xa);
> kref_put(&entry->ref, rdma_user_mmap_entry_free); }
> EXPORT_SYMBOL(rdma_user_mmap_entry_remove);
> --
Thanks,
Acked-by: Michal Kalderon <michal.kalderon@marvell.com>
> 2.24.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence
2020-01-15 20:20 [PATCH] RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence Jason Gunthorpe
2020-01-16 8:51 ` Gal Pressman
2020-01-20 11:07 ` Michal Kalderon
@ 2020-01-25 18:52 ` Jason
2 siblings, 0 replies; 5+ messages in thread
From: Jason @ 2020-01-25 18:52 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: linux-rdma, Michal Kalderon, Gal Pressman
On Wed, Jan 15, 2020 at 08:20:44PM +0000, Jason Gunthorpe wrote:
> The set of entry->driver_removed is missing locking, protect it with
> xa_lock() which is held by the only reader.
>
> Otherwise readers may continue to see driver_removed = false after
> rdma_user_mmap_entry_remove() returns and may continue to try and
> establish new mmaps.
>
> Fixes: 3411f9f01b76 ("RDMA/core: Create mmap database and cookie helper functions")
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> Reviewed-by: Gal Pressman <galpress@amazon.com>
> Acked-by: Michal Kalderon <michal.kalderon@marvell.com>
> ---
> drivers/infiniband/core/ib_core_uverbs.c | 2 ++
> 1 file changed, 2 insertions(+)
Applied to for-next
Jason
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-01-25 18:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 20:20 [PATCH] RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence Jason Gunthorpe
2020-01-16 8:51 ` Gal Pressman
2020-01-16 13:05 ` Jason Gunthorpe
2020-01-20 11:07 ` Michal Kalderon
2020-01-25 18:52 ` Jason
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).