Date: Mon, 13 Mar 2017 10:41:47 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315193 - stable/11/sys/kern Message-ID: <201703131041.v2DAfl3o093677@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Mon Mar 13 10:41:47 2017 New Revision: 315193 URL: https://svnweb.freebsd.org/changeset/base/315193 Log: MFC r314486: When deallocating the vm object in elf_map_insert() due to vm_map_insert() failure, drop the vnode lock around the call to vm_object_deallocate(). Modified: stable/11/sys/kern/imgact_elf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/imgact_elf.c ============================================================================== --- stable/11/sys/kern/imgact_elf.c Mon Mar 13 09:04:10 2017 (r315192) +++ stable/11/sys/kern/imgact_elf.c Mon Mar 13 10:41:47 2017 (r315193) @@ -421,13 +421,14 @@ __elfN(map_partial)(vm_map_t map, vm_obj } static int -__elfN(map_insert)(vm_map_t map, vm_object_t object, vm_ooffset_t offset, - vm_offset_t start, vm_offset_t end, vm_prot_t prot, int cow) +__elfN(map_insert)(struct image_params *imgp, vm_map_t map, vm_object_t object, + vm_ooffset_t offset, vm_offset_t start, vm_offset_t end, vm_prot_t prot, + int cow) { struct sf_buf *sf; vm_offset_t off; vm_size_t sz; - int error, rv; + int error, locked, rv; if (start != trunc_page(start)) { rv = __elfN(map_partial)(map, object, offset, start, @@ -479,8 +480,12 @@ __elfN(map_insert)(vm_map_t map, vm_obje rv = vm_map_insert(map, object, offset, start, end, prot, VM_PROT_ALL, cow); vm_map_unlock(map); - if (rv != KERN_SUCCESS) + if (rv != KERN_SUCCESS) { + locked = VOP_ISLOCKED(imgp->vp); + VOP_UNLOCK(imgp->vp, 0); vm_object_deallocate(object); + vn_lock(imgp->vp, locked | LK_RETRY); + } } return (rv); } else { @@ -537,7 +542,7 @@ __elfN(load_section)(struct image_params cow = MAP_COPY_ON_WRITE | MAP_PREFAULT | (prot & VM_PROT_WRITE ? 0 : MAP_DISABLE_COREDUMP); - rv = __elfN(map_insert)(map, + rv = __elfN(map_insert)(imgp, map, object, file_addr, /* file offset */ map_addr, /* virtual start */ @@ -567,8 +572,8 @@ __elfN(load_section)(struct image_params /* This had damn well better be true! */ if (map_len != 0) { - rv = __elfN(map_insert)(map, NULL, 0, map_addr, map_addr + - map_len, VM_PROT_ALL, 0); + rv = __elfN(map_insert)(imgp, map, NULL, 0, map_addr, + map_addr + map_len, VM_PROT_ALL, 0); if (rv != KERN_SUCCESS) { return (EINVAL); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703131041.v2DAfl3o093677>