diff options
author | jeff <jeff@FreeBSD.org> | 2002-08-13 06:55:28 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2002-08-13 06:55:28 +0000 |
commit | a996673e123dab0805b05084774227cae72d75e5 (patch) | |
tree | 9e630263213e8fdda8c938a92f150220b0eb745d /sys/compat | |
parent | 216ea61cb629b077f8cf1b29f90f2c08ff1b1eea (diff) | |
download | FreeBSD-src-a996673e123dab0805b05084774227cae72d75e5.zip FreeBSD-src-a996673e123dab0805b05084774227cae72d75e5.tar.gz |
- Hold the vnode lock throughout execve.
- Set VV_TEXT in the top level execve code.
- Fixup the image activators to deal with the newly locked vnode.
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/pecoff/imgact_pecoff.c | 15 | ||||
-rw-r--r-- | sys/compat/svr4/imgact_svr4.c | 26 |
2 files changed, 23 insertions, 18 deletions
diff --git a/sys/compat/pecoff/imgact_pecoff.c b/sys/compat/pecoff/imgact_pecoff.c index 175b021..f7b540c 100644 --- a/sys/compat/pecoff/imgact_pecoff.c +++ b/sys/compat/pecoff/imgact_pecoff.c @@ -533,8 +533,6 @@ exec_pecoff_coff_prep_zmagic(struct image_params * imgp, imgp->auxarg_size = sizeof(struct pecoff_args); imgp->interpreted = 0; - mp_fixme("Unlocked vflag access."); - imgp->vp->v_vflag |= VV_TEXT; if (sh != NULL) free(sh, M_TEMP); return 0; @@ -628,21 +626,26 @@ imgact_pecoff(struct image_params * imgp) imgp->image_header; struct coff_filehdr *fp; int error, peofs; + struct thread *td = curthread; + error = pecoff_signature(FIRST_THREAD_IN_PROC(imgp->proc), imgp->vp, dp); if (error) { return -1; } + VOP_UNLOCK(imgp->vp, 0, td); + peofs = dp->d_peofs + sizeof(signature) - 1; fp = malloc(PECOFF_HDR_SIZE, M_TEMP, M_WAITOK); error = pecoff_read_from(FIRST_THREAD_IN_PROC(imgp->proc), imgp->vp, peofs, (caddr_t) fp, PECOFF_HDR_SIZE); - if (error) { - free(fp, M_TEMP); - return error; - } + if (error) + goto fail; + error = exec_pecoff_coff_makecmds(imgp, fp, peofs); +fail: free(fp, M_TEMP); + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY, td); return error; } diff --git a/sys/compat/svr4/imgact_svr4.c b/sys/compat/svr4/imgact_svr4.c index c8b0e1f8..3104291 100644 --- a/sys/compat/svr4/imgact_svr4.c +++ b/sys/compat/svr4/imgact_svr4.c @@ -67,6 +67,7 @@ exec_svr4_imgact(imgp) vm_offset_t buffer; unsigned long bss_size; int error; + struct thread *td = curthread; if (((a_out->a_magic >> 16) & 0xff) != 0x64) return -1; @@ -111,10 +112,12 @@ exec_svr4_imgact(imgp) a_out->a_data + bss_size > imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur) return (ENOMEM); + VOP_UNLOCK(imgp->vp, 0, td); + /* copy in arguments and/or environment from old process */ error = exec_extract_strings(imgp); if (error) - return (error); + goto fail; /* * Destroy old process VM and create a new one (with a new stack) @@ -139,14 +142,14 @@ exec_svr4_imgact(imgp) a_out->a_text + a_out->a_data + bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) - return error; + goto fail; error = vm_mmap(kernel_map, &buffer, round_page(a_out->a_text + a_out->a_data + file_offset), VM_PROT_READ, VM_PROT_READ, 0, (caddr_t) imgp->vp, trunc_page(file_offset)); if (error) - return error; + goto fail; error = copyout((caddr_t)(buffer + file_offset), (caddr_t)vmaddr, a_out->a_text + a_out->a_data); @@ -155,7 +158,7 @@ exec_svr4_imgact(imgp) buffer + round_page(a_out->a_text + a_out->a_data + file_offset)); if (error) - return error; + goto fail; /* * remove write enable on the 'text' part @@ -166,7 +169,7 @@ exec_svr4_imgact(imgp) VM_PROT_EXECUTE|VM_PROT_READ, TRUE); if (error) - return error; + goto fail; } else { #ifdef DEBUG @@ -183,7 +186,7 @@ exec_svr4_imgact(imgp) MAP_PRIVATE | MAP_FIXED, (caddr_t)imgp->vp, file_offset); if (error) - return (error); + goto fail; #ifdef DEBUG printf("imgact: startaddr=%08lx, length=%08lx\n", (u_long)vmaddr, @@ -198,7 +201,7 @@ exec_svr4_imgact(imgp) VM_PROT_ALL, FALSE); if (error) - return (error); + goto fail; /* * Allocate anon demand-zeroed area for uninitialized data @@ -208,16 +211,13 @@ exec_svr4_imgact(imgp) error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr, bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) - return (error); + goto fail; #ifdef DEBUG printf("imgact: bssaddr=%08lx, length=%08lx\n", (u_long)vmaddr, bss_size); #endif } - /* Indicate that this file should not be modified */ - mp_fixme("Unlocked vflag access."); - imgp->vp->v_vflag |= VV_TEXT; } /* Fill in process VM information */ vmspace->vm_tsize = round_page(a_out->a_text) >> PAGE_SHIFT; @@ -230,7 +230,9 @@ exec_svr4_imgact(imgp) imgp->entry_addr = a_out->a_entry; imgp->proc->p_sysent = &svr4_sysvec; - return (0); +fail: + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + return (error); } /* |