Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/core: Ensure that rdma_user_mmap_entry_remove() is a fence

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")
Link: https://lore.kernel.org/r/20200115202041.GA17199@ziepe.ca
Reviewed-by: Gal Pressman <galpress@amazon.com>
Acked-by: Michal Kalderon <michal.kalderon@marvell.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

+2
+2
drivers/infiniband/core/ib_core_uverbs.c
··· 232 232 if (!entry) 233 233 return; 234 234 235 + xa_lock(&entry->ucontext->mmap_xa); 235 236 entry->driver_removed = true; 237 + xa_unlock(&entry->ucontext->mmap_xa); 236 238 kref_put(&entry->ref, rdma_user_mmap_entry_free); 237 239 } 238 240 EXPORT_SYMBOL(rdma_user_mmap_entry_remove);