diff options
author | Leon Romanovsky <leonro@mellanox.com> | 2017-05-21 12:08:09 -0400 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2017-06-01 17:20:13 -0400 |
commit | 79bb5b7ee1776a244484a1be6671d89fbd7c0c9f (patch) | |
tree | 3671e82e4056918be2e57a1ec1df88d3607d35c4 /drivers | |
parent | 53376fedb9da54c0d3b0bd3a6edcbeb681692909 (diff) |
RDMA/umem: Fix missing mmap_sem in get umem ODP call
Add mmap_sem lock around VMA inspection in ib_umem_odp_get().
Fixes: 0008b84ea9af ('IB/umem: Add support to huge ODP')
Signed-off-by: Artemy Kovalyov <artemyko@mellanox.com>
Reviewed-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/core/umem_odp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c index 0780b1afefa9..8c4ec564e495 100644 --- a/drivers/infiniband/core/umem_odp.c +++ b/drivers/infiniband/core/umem_odp.c | |||
@@ -321,11 +321,15 @@ int ib_umem_odp_get(struct ib_ucontext *context, struct ib_umem *umem, | |||
321 | struct vm_area_struct *vma; | 321 | struct vm_area_struct *vma; |
322 | struct hstate *h; | 322 | struct hstate *h; |
323 | 323 | ||
324 | down_read(&mm->mmap_sem); | ||
324 | vma = find_vma(mm, ib_umem_start(umem)); | 325 | vma = find_vma(mm, ib_umem_start(umem)); |
325 | if (!vma || !is_vm_hugetlb_page(vma)) | 326 | if (!vma || !is_vm_hugetlb_page(vma)) { |
327 | up_read(&mm->mmap_sem); | ||
326 | return -EINVAL; | 328 | return -EINVAL; |
329 | } | ||
327 | h = hstate_vma(vma); | 330 | h = hstate_vma(vma); |
328 | umem->page_shift = huge_page_shift(h); | 331 | umem->page_shift = huge_page_shift(h); |
332 | up_read(&mm->mmap_sem); | ||
329 | umem->hugetlb = 1; | 333 | umem->hugetlb = 1; |
330 | } else { | 334 | } else { |
331 | umem->hugetlb = 0; | 335 | umem->hugetlb = 0; |