]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
RDMA/odp: Ensure the mm is still alive before creating an implicit child
authorJason Gunthorpe <jgg@mellanox.com>
Thu, 27 Feb 2020 11:41:18 +0000 (13:41 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Mar 2020 06:18:44 +0000 (07:18 +0100)
commit25c839fde2785c574b41cf4e1af76fba7c1edbe7
tree73eb3f70b3db3b27cd19c576c5fa063075e5318a
parent0f72324e796fe6baa6da659dd09089d45e4adb09
RDMA/odp: Ensure the mm is still alive before creating an implicit child

commit a4e63bce1414df7ab6eb82ca9feb8494ce13e554 upstream.

Registration of a mmu_notifier requires the caller to hold a mmget() on
the mm as registration is not permitted to race with exit_mmap(). There is
a BUG_ON inside the mmu_notifier to guard against this.

Normally creating a umem is done against current which implicitly holds
the mmget(), however an implicit ODP child is created from a pagefault
work queue and is not guaranteed to have a mmget().

Call mmget() around this registration and abort faulting if the MM has
gone to exit_mmap().

Before the patch below the notifier was registered when the implicit ODP
parent was created, so there was no chance to register a notifier outside
of current.

Fixes: c571feca2dc9 ("RDMA/odp: use mmu_notifier_get/put for 'struct ib_ucontext_per_mm'")
Link: https://lore.kernel.org/r/20200227114118.94736-1-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/core/umem_odp.c