From owner-svn-src-head@freebsd.org Wed May 31 13:01:28 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80A86B795D2; Wed, 31 May 2017 13:01:28 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 51098776E4; Wed, 31 May 2017 13:01:28 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4VD1R2q028899; Wed, 31 May 2017 13:01:27 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4VD1ReD028897; Wed, 31 May 2017 13:01:27 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201705311301.v4VD1ReD028897@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 31 May 2017 13:01:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319318 - in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 May 2017 13:01:28 -0000 Author: hselasky Date: Wed May 31 13:01:27 2017 New Revision: 319318 URL: https://svnweb.freebsd.org/changeset/base/319318 Log: 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 Modified: head/sys/compat/linuxkpi/common/include/linux/mm_types.h head/sys/compat/linuxkpi/common/src/linux_current.c head/sys/compat/linuxkpi/common/src/linux_page.c Modified: head/sys/compat/linuxkpi/common/include/linux/mm_types.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/mm_types.h Wed May 31 12:08:25 2017 (r319317) +++ head/sys/compat/linuxkpi/common/include/linux/mm_types.h Wed May 31 13:01:27 2017 (r319318) @@ -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; Modified: head/sys/compat/linuxkpi/common/src/linux_current.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_current.c Wed May 31 12:08:25 2017 (r319317) +++ head/sys/compat/linuxkpi/common/src/linux_current.c Wed May 31 13:01:27 2017 (r319318) @@ -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); } Modified: head/sys/compat/linuxkpi/common/src/linux_page.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_page.c Wed May 31 12:08:25 2017 (r319317) +++ head/sys/compat/linuxkpi/common/src/linux_page.c Wed May 31 13:01:27 2017 (r319318) @@ -268,7 +268,7 @@ get_user_pages_remote(struct task_struct *task, struct { 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)); }