]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
IB/mthca: Fix gup usage in mthca_map_user_db()
authorDavidlohr Bueso <dave@stgolabs.net>
Thu, 25 Jan 2018 19:27:27 +0000 (11:27 -0800)
committerDoug Ledford <dledford@redhat.com>
Fri, 26 Jan 2018 15:43:46 +0000 (10:43 -0500)
get_user_pages() must be called with mmap_sem held, currently
it is not. In fact it is called under the user db_table->mutex.
To fix this we can convert gup to use the fast alternative,
and safely avoid taking mmap_sem, if possible. Furthermore
this is safe wrt to the mutex as other callers that take the
lock (unmap and alloc_db) are not called under mmap_sem
(hence possible deadlock).

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mthca/mthca_memfree.c

index 2a41ed74add88449f9a286b9299ed9ffa609077a..2fe503e86c1dda3ed666062c2e21c2f73ef45935 100644 (file)
@@ -472,7 +472,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
                goto out;
        }
 
-       ret = get_user_pages(uaddr & PAGE_MASK, 1, FOLL_WRITE, pages, NULL);
+       ret = get_user_pages_fast(uaddr & PAGE_MASK, 1, FOLL_WRITE, pages);
        if (ret < 0)
                goto out;