Deleted Added
full compact
kern_exec.c (15494) kern_exec.c (15809)
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

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
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

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: kern_exec.c,v 1.39 1996/04/29 15:07:59 smpatel Exp $
26 * $Id: kern_exec.c,v 1.40 1996/05/01 02:42:47 bde Exp $
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/sysproto.h>
32#include <sys/signalvar.h>
33#include <sys/kernel.h>
34#include <sys/mount.h>

--- 131 unchanged lines hidden (view full) ---

166
167 if (error)
168 goto exec_fail_dealloc;
169
170 /*
171 * Map the image header (first page) of the file into
172 * kernel address space
173 */
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/sysproto.h>
32#include <sys/signalvar.h>
33#include <sys/kernel.h>
34#include <sys/mount.h>

--- 131 unchanged lines hidden (view full) ---

166
167 if (error)
168 goto exec_fail_dealloc;
169
170 /*
171 * Map the image header (first page) of the file into
172 * kernel address space
173 */
174 error = vm_mmap(kernel_map, /* map */
174 error = vm_mmap(exech_map, /* map */
175 (vm_offset_t *)&imgp->image_header, /* address */
176 PAGE_SIZE, /* size */
177 VM_PROT_READ, /* protection */
178 VM_PROT_READ, /* max protection */
179 0, /* flags */
180 (caddr_t)imgp->vp, /* vnode */
181 0); /* offset */
182 if (error) {

--- 18 unchanged lines hidden (view full) ---

201 if (error == -1)
202 continue;
203 if (error)
204 goto exec_fail_dealloc;
205 if (imgp->interpreted) {
206 /* free old vnode and name buffer */
207 vrele(ndp->ni_vp);
208 FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI);
175 (vm_offset_t *)&imgp->image_header, /* address */
176 PAGE_SIZE, /* size */
177 VM_PROT_READ, /* protection */
178 VM_PROT_READ, /* max protection */
179 0, /* flags */
180 (caddr_t)imgp->vp, /* vnode */
181 0); /* offset */
182 if (error) {

--- 18 unchanged lines hidden (view full) ---

201 if (error == -1)
202 continue;
203 if (error)
204 goto exec_fail_dealloc;
205 if (imgp->interpreted) {
206 /* free old vnode and name buffer */
207 vrele(ndp->ni_vp);
208 FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI);
209 if (vm_map_remove(kernel_map, (vm_offset_t)imgp->image_header,
209 if (vm_map_remove(exech_map, (vm_offset_t)imgp->image_header,
210 (vm_offset_t)imgp->image_header + PAGE_SIZE))
211 panic("execve: header dealloc failed (1)");
212
213 /* set new name to that of the interpreter */
214 NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME,
215 UIO_SYSSPACE, imgp->interpreter_name, p);
216 goto interpret;
217 }

--- 96 unchanged lines hidden (view full) ---

314
315 /* Set entry address */
316 setregs(p, imgp->entry_addr, (u_long)stack_base);
317
318 /*
319 * free various allocated resources
320 */
321 kmem_free(exec_map, (vm_offset_t)imgp->stringbase, ARG_MAX);
210 (vm_offset_t)imgp->image_header + PAGE_SIZE))
211 panic("execve: header dealloc failed (1)");
212
213 /* set new name to that of the interpreter */
214 NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME,
215 UIO_SYSSPACE, imgp->interpreter_name, p);
216 goto interpret;
217 }

--- 96 unchanged lines hidden (view full) ---

314
315 /* Set entry address */
316 setregs(p, imgp->entry_addr, (u_long)stack_base);
317
318 /*
319 * free various allocated resources
320 */
321 kmem_free(exec_map, (vm_offset_t)imgp->stringbase, ARG_MAX);
322 if (vm_map_remove(kernel_map, (vm_offset_t)imgp->image_header,
322 if (vm_map_remove(exech_map, (vm_offset_t)imgp->image_header,
323 (vm_offset_t)imgp->image_header + PAGE_SIZE))
324 panic("execve: header dealloc failed (2)");
325 vrele(ndp->ni_vp);
326 FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI);
327
328 return (0);
329
330exec_fail_dealloc:
331 if (imgp->stringbase != NULL)
332 kmem_free(exec_map, (vm_offset_t)imgp->stringbase, ARG_MAX);
333 if (imgp->image_header && imgp->image_header != (char *)-1)
323 (vm_offset_t)imgp->image_header + PAGE_SIZE))
324 panic("execve: header dealloc failed (2)");
325 vrele(ndp->ni_vp);
326 FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI);
327
328 return (0);
329
330exec_fail_dealloc:
331 if (imgp->stringbase != NULL)
332 kmem_free(exec_map, (vm_offset_t)imgp->stringbase, ARG_MAX);
333 if (imgp->image_header && imgp->image_header != (char *)-1)
334 if (vm_map_remove(kernel_map, (vm_offset_t)imgp->image_header,
334 if (vm_map_remove(exech_map, (vm_offset_t)imgp->image_header,
335 (vm_offset_t)imgp->image_header + PAGE_SIZE))
336 panic("execve: header dealloc failed (3)");
337 if (ndp->ni_vp)
338 vrele(ndp->ni_vp);
339 FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI);
340
341exec_fail:
342 if (imgp->vmspace_destroyed) {

--- 274 unchanged lines hidden ---
335 (vm_offset_t)imgp->image_header + PAGE_SIZE))
336 panic("execve: header dealloc failed (3)");
337 if (ndp->ni_vp)
338 vrele(ndp->ni_vp);
339 FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI);
340
341exec_fail:
342 if (imgp->vmspace_destroyed) {

--- 274 unchanged lines hidden ---