kern_sharedpage.c (12221) | kern_sharedpage.c (12258) |
---|---|
1/* 2 * Copyright (c) 1993, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * | 1/* 2 * Copyright (c) 1993, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * |
31 * $Id: kern_exec.c,v 1.25 1995/11/06 12:52:32 davidg Exp $ | 31 * $Id: kern_exec.c,v 1.26 1995/11/12 06:42:53 bde Exp $ |
32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/sysproto.h> 37#include <sys/signalvar.h> 38#include <sys/kernel.h> 39#include <sys/mount.h> --- 60 unchanged lines hidden (view full) --- 100 imgp->vmspace_destroyed = 0; 101 imgp->interpreted = 0; 102 imgp->interpreter_name[0] = '\0'; 103 104 /* 105 * Allocate temporary demand zeroed space for argument and 106 * environment strings 107 */ | 32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/sysproto.h> 37#include <sys/signalvar.h> 38#include <sys/kernel.h> 39#include <sys/mount.h> --- 60 unchanged lines hidden (view full) --- 100 imgp->vmspace_destroyed = 0; 101 imgp->interpreted = 0; 102 imgp->interpreter_name[0] = '\0'; 103 104 /* 105 * Allocate temporary demand zeroed space for argument and 106 * environment strings 107 */ |
108 imgp->stringbase = (char *)vm_map_min(exec_map); 109 error = vm_map_find(exec_map, NULL, 0, (vm_offset_t *)&imgp->stringbase, 110 ARG_MAX, TRUE); 111 if (error) { 112 log(LOG_WARNING, "execve: failed to allocate string space\n"); 113 return (error); 114 } 115 116 if (!imgp->stringbase) { | 108 imgp->stringbase = (char *)kmem_alloc_pageable(exec_map, ARG_MAX); 109 if (imgp->stringbase == NULL) { |
117 error = ENOMEM; 118 goto exec_fail; 119 } 120 imgp->stringp = imgp->stringbase; 121 imgp->stringspace = ARG_MAX; 122 123 /* 124 * Translate the file name. namei() returns a vnode pointer 125 * in ni_vp amoung other things. 126 */ 127 ndp = &nd; 128 NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, 129 UIO_USERSPACE, uap->fname, p); 130 131interpret: 132 133 error = namei(ndp); 134 if (error) { | 110 error = ENOMEM; 111 goto exec_fail; 112 } 113 imgp->stringp = imgp->stringbase; 114 imgp->stringspace = ARG_MAX; 115 116 /* 117 * Translate the file name. namei() returns a vnode pointer 118 * in ni_vp amoung other things. 119 */ 120 ndp = &nd; 121 NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, 122 UIO_USERSPACE, uap->fname, p); 123 124interpret: 125 126 error = namei(ndp); 127 if (error) { |
135 vm_map_remove(exec_map, (vm_offset_t)imgp->stringbase, 136 (vm_offset_t)imgp->stringbase + ARG_MAX); | 128 kmem_free(exec_map, (vm_offset_t)imgp->stringbase, ARG_MAX); |
137 goto exec_fail; 138 } 139 140 imgp->vp = ndp->ni_vp; 141 if (imgp->vp == NULL) { 142 error = ENOEXEC; 143 goto exec_fail_dealloc; 144 } --- 158 unchanged lines hidden (view full) --- 303 p->p_acflag &= ~AFORK; 304 305 /* Set entry address */ 306 setregs(p, imgp->entry_addr, (u_long)stack_base); 307 308 /* 309 * free various allocated resources 310 */ | 129 goto exec_fail; 130 } 131 132 imgp->vp = ndp->ni_vp; 133 if (imgp->vp == NULL) { 134 error = ENOEXEC; 135 goto exec_fail_dealloc; 136 } --- 158 unchanged lines hidden (view full) --- 295 p->p_acflag &= ~AFORK; 296 297 /* Set entry address */ 298 setregs(p, imgp->entry_addr, (u_long)stack_base); 299 300 /* 301 * free various allocated resources 302 */ |
311 if (vm_map_remove(exec_map, (vm_offset_t)imgp->stringbase, 312 (vm_offset_t)imgp->stringbase + ARG_MAX)) 313 panic("execve: string buffer dealloc failed (1)"); | 303 kmem_free(exec_map, (vm_offset_t)imgp->stringbase, ARG_MAX); |
314 if (vm_map_remove(kernel_map, (vm_offset_t)imgp->image_header, 315 (vm_offset_t)imgp->image_header + PAGE_SIZE)) 316 panic("execve: header dealloc failed (2)"); 317 vrele(ndp->ni_vp); 318 FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI); 319 320 return (0); 321 322exec_fail_dealloc: | 304 if (vm_map_remove(kernel_map, (vm_offset_t)imgp->image_header, 305 (vm_offset_t)imgp->image_header + PAGE_SIZE)) 306 panic("execve: header dealloc failed (2)"); 307 vrele(ndp->ni_vp); 308 FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI); 309 310 return (0); 311 312exec_fail_dealloc: |
323 if (imgp->stringbase && imgp->stringbase != (char *)-1) 324 if (vm_map_remove(exec_map, (vm_offset_t)imgp->stringbase, 325 (vm_offset_t)imgp->stringbase + ARG_MAX)) 326 panic("execve: string buffer dealloc failed (2)"); | 313 if (imgp->stringbase != NULL) 314 kmem_free(exec_map, (vm_offset_t)imgp->stringbase, ARG_MAX); |
327 if (imgp->image_header && imgp->image_header != (char *)-1) 328 if (vm_map_remove(kernel_map, (vm_offset_t)imgp->image_header, 329 (vm_offset_t)imgp->image_header + PAGE_SIZE)) 330 panic("execve: header dealloc failed (3)"); 331 if (ndp->ni_vp) 332 vrele(ndp->ni_vp); 333 FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI); 334 --- 253 unchanged lines hidden --- | 315 if (imgp->image_header && imgp->image_header != (char *)-1) 316 if (vm_map_remove(kernel_map, (vm_offset_t)imgp->image_header, 317 (vm_offset_t)imgp->image_header + PAGE_SIZE)) 318 panic("execve: header dealloc failed (3)"); 319 if (ndp->ni_vp) 320 vrele(ndp->ni_vp); 321 FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI); 322 --- 253 unchanged lines hidden --- |