Don't acquire a reference on the VM-space when allocating the LinuxKPI

task structure to avoid deadlock when tearing down the VM object
during a process exit.

Found by:		markj @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2017-05-31 13:01:27 +00:00
parent ea67550be0
commit 68b9f2f00c
3 changed files with 2 additions and 7 deletions

View file

@ -38,11 +38,9 @@
struct vm_area_struct;
struct task_struct;
struct vmspace;
struct mm_struct {
struct vm_area_struct *mmap;
struct vmspace *vmspace;
atomic_t mm_count;
atomic_t mm_users;
size_t pinned_vm;

View file

@ -96,7 +96,6 @@ linux_alloc_current(struct thread *td, int flags)
init_rwsem(&mm->mmap_sem);
atomic_set(&mm->mm_count, 1);
atomic_set(&mm->mm_users, 1);
mm->vmspace = vmspace_acquire_ref(proc);
/* set mm_struct pointer */
ts->mm = mm;
/* clear pointer to not free memory */
@ -119,7 +118,7 @@ linux_get_task_mm(struct task_struct *task)
struct mm_struct *mm;
mm = task->mm;
if (mm != NULL && mm->vmspace != NULL) {
if (mm != NULL) {
atomic_inc(&mm->mm_users);
return (mm);
}
@ -129,8 +128,6 @@ linux_get_task_mm(struct task_struct *task)
void
linux_mm_dtor(struct mm_struct *mm)
{
if (mm->vmspace != NULL)
vmspace_free(mm->vmspace);
free(mm, M_LINUX_CURRENT);
}

View file

@ -268,7 +268,7 @@ get_user_pages_remote(struct task_struct *task, struct mm_struct *mm,
{
vm_map_t map;
map = &mm->vmspace->vm_map;
map = &task->task_thread->td_proc->p_vmspace->vm_map;
return (linux_get_user_pages_internal(map, start, nr_pages,
!!(gup_flags & FOLL_WRITE), pages));
}