diff options
author | Per Fogelstrom <pefo@cvs.openbsd.org> | 1996-08-31 09:24:11 +0000 |
---|---|---|
committer | Per Fogelstrom <pefo@cvs.openbsd.org> | 1996-08-31 09:24:11 +0000 |
commit | 01bebf01277503d67e1a208085b2a86a44154993 (patch) | |
tree | 52453faa1c5020bbe77bdc7409a023f4cd45fa41 | |
parent | 29228bcb2229da01995293a5cb6e28c3788af684 (diff) |
Cleanup exec
-rw-r--r-- | sys/compat/freebsd/freebsd_exec.c | 3 | ||||
-rw-r--r-- | sys/compat/hpux/hpux_exec.c | 3 | ||||
-rw-r--r-- | sys/compat/ibcs2/ibcs2_exec.c | 3 | ||||
-rw-r--r-- | sys/compat/linux/linux_exec.c | 4 | ||||
-rw-r--r-- | sys/compat/osf1/osf1_misc.c | 3 | ||||
-rw-r--r-- | sys/compat/sunos/sunos_exec.c | 3 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_exec.c | 3 | ||||
-rw-r--r-- | sys/compat/ultrix/ultrix_misc.c | 3 | ||||
-rw-r--r-- | sys/dev/microcode/ncr53cxxx/ncr53cxxx.c | 45 | ||||
-rw-r--r-- | sys/kern/exec_elf.c | 248 | ||||
-rw-r--r-- | sys/kern/init_main.c | 3 | ||||
-rw-r--r-- | sys/kern/kern_exec.c | 14 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_lookup.c | 11 |
13 files changed, 235 insertions, 111 deletions
diff --git a/sys/compat/freebsd/freebsd_exec.c b/sys/compat/freebsd/freebsd_exec.c index 3f62598ca59..a152b17580f 100644 --- a/sys/compat/freebsd/freebsd_exec.c +++ b/sys/compat/freebsd/freebsd_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: freebsd_exec.c,v 1.3 1996/08/02 20:34:44 niklas Exp $ */ +/* $OpenBSD: freebsd_exec.c,v 1.4 1996/08/31 09:24:00 pefo Exp $ */ /* $NetBSD: freebsd_exec.c,v 1.2 1996/05/18 16:02:08 christos Exp $ */ /* @@ -59,6 +59,7 @@ struct emul emul_freebsd = { 0, copyargs, setregs, + NULL, freebsd_sigcode, freebsd_esigcode, }; diff --git a/sys/compat/hpux/hpux_exec.c b/sys/compat/hpux/hpux_exec.c index 6ecf99b7b22..0bb9dea90a6 100644 --- a/sys/compat/hpux/hpux_exec.c +++ b/sys/compat/hpux/hpux_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hpux_exec.c,v 1.4 1996/08/25 12:19:48 deraadt Exp $ */ +/* $OpenBSD: hpux_exec.c,v 1.5 1996/08/31 09:24:01 pefo Exp $ */ /* $NetBSD: hpux_exec.c,v 1.3 1996/01/06 12:44:13 thorpej Exp $ */ /* @@ -84,6 +84,7 @@ struct emul emul_hpux = { 0, copyargs, setregs, + NULL, sigcode, esigcode, }; diff --git a/sys/compat/ibcs2/ibcs2_exec.c b/sys/compat/ibcs2/ibcs2_exec.c index 32121f88b95..f91d08f4460 100644 --- a/sys/compat/ibcs2/ibcs2_exec.c +++ b/sys/compat/ibcs2/ibcs2_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ibcs2_exec.c,v 1.3 1996/08/02 20:35:04 niklas Exp $ */ +/* $OpenBSD: ibcs2_exec.c,v 1.4 1996/08/31 09:24:02 pefo Exp $ */ /* $NetBSD: ibcs2_exec.c,v 1.11 1996/05/03 17:05:19 christos Exp $ */ /* @@ -92,6 +92,7 @@ struct emul emul_ibcs2 = { 0, copyargs, setregs, + NULL, sigcode, esigcode, }; diff --git a/sys/compat/linux/linux_exec.c b/sys/compat/linux/linux_exec.c index 8221564ad73..41b9f027af0 100644 --- a/sys/compat/linux/linux_exec.c +++ b/sys/compat/linux/linux_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_exec.c,v 1.2 1996/04/17 05:23:46 mickey Exp $ */ +/* $OpenBSD: linux_exec.c,v 1.3 1996/08/31 09:24:02 pefo Exp $ */ /* $NetBSD: linux_exec.c,v 1.13 1996/04/05 00:01:10 christos Exp $ */ /* @@ -89,6 +89,7 @@ struct emul emul_linux_aout = { LINUX_AOUT_AUX_ARGSIZ, linux_aout_copyargs, setregs, + NULL, linux_sigcode, linux_esigcode, }; @@ -104,6 +105,7 @@ struct emul emul_linux_elf = { LINUX_ELF_AUX_ARGSIZ, elf_copyargs, setregs, + exec_elf_fixup, linux_sigcode, linux_esigcode, }; diff --git a/sys/compat/osf1/osf1_misc.c b/sys/compat/osf1/osf1_misc.c index ed0e94aeffc..2c1d4d172e0 100644 --- a/sys/compat/osf1/osf1_misc.c +++ b/sys/compat/osf1/osf1_misc.c @@ -1,4 +1,4 @@ -2/* $OpenBSD: osf1_misc.c,v 1.4 1996/08/25 12:19:53 deraadt Exp $ */ +2/* $OpenBSD: osf1_misc.c,v 1.5 1996/08/31 09:24:03 pefo Exp $ */ /* $NetBSD: osf1_misc.c,v 1.7 1995/10/07 06:53:04 mycroft Exp $ */ /* @@ -72,6 +72,7 @@ struct emul emul_osf1 = { 0, copyargs, cpu_exec_ecoff_setregs, + NULL, sigcode, esigcode, }; diff --git a/sys/compat/sunos/sunos_exec.c b/sys/compat/sunos/sunos_exec.c index b07fdc27b67..4c3c19243f9 100644 --- a/sys/compat/sunos/sunos_exec.c +++ b/sys/compat/sunos/sunos_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunos_exec.c,v 1.5 1996/05/10 12:50:23 deraadt Exp $ */ +/* $OpenBSD: sunos_exec.c,v 1.6 1996/08/31 09:24:04 pefo Exp $ */ /* $NetBSD: sunos_exec.c,v 1.11 1996/05/05 12:01:47 briggs Exp $ */ /* @@ -96,6 +96,7 @@ struct emul emul_sunos = { 0, copyargs, setregs, + NULL, sigcode, esigcode, }; diff --git a/sys/compat/svr4/svr4_exec.c b/sys/compat/svr4/svr4_exec.c index dabbe692999..7639f8b0a21 100644 --- a/sys/compat/svr4/svr4_exec.c +++ b/sys/compat/svr4/svr4_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_exec.c,v 1.3 1996/08/02 20:35:37 niklas Exp $ */ +/* $OpenBSD: svr4_exec.c,v 1.4 1996/08/31 09:24:05 pefo Exp $ */ /* $NetBSD: svr4_exec.c,v 1.16 1995/10/14 20:24:20 christos Exp $ */ /* @@ -71,6 +71,7 @@ struct emul emul_svr4 = { SVR4_AUX_ARGSIZ, svr4_copyargs, setregs, + NULL, svr4_sigcode, svr4_esigcode, }; diff --git a/sys/compat/ultrix/ultrix_misc.c b/sys/compat/ultrix/ultrix_misc.c index 046cc440349..e913dd78ed9 100644 --- a/sys/compat/ultrix/ultrix_misc.c +++ b/sys/compat/ultrix/ultrix_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ultrix_misc.c,v 1.9 1996/08/25 12:20:02 deraadt Exp $ */ +/* $OpenBSD: ultrix_misc.c,v 1.10 1996/08/31 09:24:06 pefo Exp $ */ /* $NetBSD: ultrix_misc.c,v 1.23 1996/04/07 17:23:04 jonathan Exp $ */ /* @@ -157,6 +157,7 @@ struct emul emul_ultrix = { 0, copyargs, ULTRIX_EXEC_SETREGS, + NULL, sigcode, esigcode, }; diff --git a/sys/dev/microcode/ncr53cxxx/ncr53cxxx.c b/sys/dev/microcode/ncr53cxxx/ncr53cxxx.c index 964c7bdb14e..e57ed8c7ce6 100644 --- a/sys/dev/microcode/ncr53cxxx/ncr53cxxx.c +++ b/sys/dev/microcode/ncr53cxxx/ncr53cxxx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncr53cxxx.c,v 1.1 1996/08/10 12:23:10 deraadt Exp $ */ +/* $OpenBSD: ncr53cxxx.c,v 1.2 1996/08/31 09:24:07 pefo Exp $ */ /* * Copyright (c) 1995 Michael L. Hitch @@ -127,7 +127,7 @@ char *phases[] = { "res4", "res5", "msg_out", "msg_in" }; -char *regs[] = { +char *regs710[] = { "scntl0", "scntl1", "sdid", "sien", "scid", "sxfer", "sodl", "socl", "sfbr", "sidl", "sbdl", "sbcl", @@ -146,8 +146,36 @@ char *regs[] = { "addr0", "addr1", "addr2", "addr3" }; +char *regs720[] = { + "scntl0", "scntl1", "scntl2", "scntl3", + "scid", "sxfer", "sdid", "gpreg", + "sfbr", "socl", "ssid", "sbcl", + "dstat", "sstat0", "sstat1", "sstat2", + "dsa0", "dsa1", "dsa2", "dsa3", + "istat", "", "", "", + "ctest0", "ctest1", "ctest2", "ctest3", + "temp0", "temp1", "temp2", "temp3", + "dfifo", "ctest4", "ctest5", "ctest6", + "dbc0", "dbc1", "dbc2", "dcmd", + "dnad0", "dnad1", "dnad2", "dnad3", + "dsp0", "dsp1", "dsp2", "dsp3", + "dsps0", "dsps1", "dsps2", "dsps3", + "scratcha0", "scratcha1", "scratcha2", "scratcha3", + "dmode", "dien", "dwt", "dcntl", + "addr0", "addr1", "addr2", "addr3", + "sien0", "sien1", "sist0", "sist1", + "slpar", "swide", "macntl", "gpcntl", + "stime0", "stime1", "respid0", "respid1", + "stest0", "stest1", "stest2", "stest3", + "sidl0", "sidl1", "", "", + "sodl0", "sodl1", "", "", + "sbdl0", "sbdl1", "", "", + "scratchb0", "scratchb1", "scratchb2", "scratchb3", +}; + int lineno; int err_listed; +int arch = 720; char inbuf[128]; @@ -516,9 +544,16 @@ int CheckRegister (int t) { int i; - for (i = 0; i < 64; ++i) - if (reserved (regs[i], t)) - return i; + if(arch == 710) { + for (i = 0; i < 64; ++i) + if (reserved (regs710[i], t)) + return i; + } + else if (arch == 720) { + for (i = 0; i < 96; ++i) + if (reserved (regs720[i], t)) + return i; + } return (-1); } diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index e8c1773d389..3d8672c3425 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,7 +1,9 @@ -/* $OpenBSD: exec_elf.c,v 1.13 1996/08/05 10:48:18 niklas Exp $ */ -/* $NetBSD: exec_elf.c,v 1.6 1996/02/09 18:59:18 christos Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.14 1996/08/31 09:24:07 pefo Exp $ */ /* + * Copyright (c) 1996 Per Fogelstrom + * All rights reserved. + * * Copyright (c) 1994 Christos Zoulas * All rights reserved. * @@ -34,12 +36,15 @@ #include <sys/kernel.h> #include <sys/proc.h> #include <sys/malloc.h> +#include <sys/mount.h> #include <sys/namei.h> #include <sys/vnode.h> #include <sys/exec.h> #include <sys/exec_elf.h> +#include <sys/file.h> #include <sys/syscall.h> #include <sys/signalvar.h> +#include <sys/stat.h> #if defined(COMPAT_LINUX) || defined(COMPAT_SVR4) /*XXX should be */ #undef EXEC_ELF /*XXX defined in */ @@ -75,15 +80,16 @@ int (*elf_probe_funcs[]) __P((struct proc *, struct exec_package *, #endif }; -int elf_check_header __P((Elf32_Ehdr *, int)); -int elf_load_file __P((struct proc *, char *, struct exec_vmcmd_set *, - u_long *, struct elf_args *, u_long *)); +int elf_load_file __P((struct proc *, char *, struct exec_package *, + struct elf_args *, u_long *)); -static int elf_read_from __P((struct proc *, struct vnode *, u_long, - caddr_t, int)); +static int elf_check_header __P((Elf32_Ehdr *, int)); +static int elf_read_from __P((struct proc *, struct vnode *, u_long, caddr_t, int)); static void elf_load_psection __P((struct exec_vmcmd_set *, struct vnode *, Elf32_Phdr *, u_long *, u_long *, int *)); +int exec_elf_fixup __P((struct proc *, struct exec_package *)); + #define ELF_ALIGN(a, b) ((a) & ~((b) - 1)) /* @@ -110,6 +116,7 @@ struct emul emul_elf = { sizeof(AuxInfo) * ELF_AUX_ENTRIES, elf_copyargs, setregs, + exec_elf_fixup, sigcode, esigcode, }; @@ -117,7 +124,7 @@ struct emul emul_elf = { /* * Copy arguments onto the stack in the normal way, but add some - * extra information in case of dynamic binding. + * space for extra information in case of dynamic binding. */ void * elf_copyargs(pack, arginfo, stack, argp) @@ -126,58 +133,17 @@ elf_copyargs(pack, arginfo, stack, argp) void *stack; void *argp; { - size_t len; - AuxInfo ai[ELF_AUX_ENTRIES], *a; - struct elf_args *ap; - stack = copyargs(pack, arginfo, stack, argp); if (!stack) return NULL; /* - * Push extra arguments on the stack needed by dynamically - * linked binaries + * Push space for extra arguments on the stack needed by + * dynamically linked binaries */ - if ((ap = (struct elf_args *) pack->ep_emul_arg)) { - a = ai; - - a->au_id = AUX_phdr; - a->au_v = ap->arg_phaddr; - a++; - - a->au_id = AUX_phent; - a->au_v = ap->arg_phentsize; - a++; - - a->au_id = AUX_phnum; - a->au_v = ap->arg_phnum; - a++; - - a->au_id = AUX_pagesz; - a->au_v = NBPG; - a++; - - a->au_id = AUX_base; - a->au_v = ap->arg_interp; - a++; - - a->au_id = AUX_flags; - a->au_v = 0; - a++; - - a->au_id = AUX_entry; - a->au_v = ap->arg_entry; - a++; - - a->au_id = AUX_null; - a->au_v = 0; - a++; - - free((char *) ap, M_TEMP); - len = ELF_AUX_ENTRIES * sizeof (AuxInfo); - if (copyout(ai, stack, len)) - return NULL; - stack += len; + if (pack->ep_interp != NULL) { + pack->ep_emul_argp = stack; + stack += ELF_AUX_ENTRIES * sizeof (AuxInfo); } return stack; } @@ -187,16 +153,15 @@ elf_copyargs(pack, arginfo, stack, argp) * * Check header for validity; return 0 for ok, ENOEXEC if error */ -int +static int elf_check_header(ehdr, type) Elf32_Ehdr *ehdr; int type; { /* - * We need to check magic, class size, endianess, - * and version before we look at the rest of the - * Elf32_Ehdr structure. These few elements are - * represented in a machine independant fashion. + * We need to check magic, class size, endianess, and version before + * we look at the rest of the Elf32_Ehdr structure. These few elements + * are represented in a machine independant fashion. */ if (!IS_ELF(*ehdr) || ehdr->e_ident[EI_CLASS] != ELF_TARG_CLASS || @@ -294,9 +259,9 @@ elf_load_psection(vcset, vp, ph, addr, size, prot) */ static int elf_read_from(p, vp, off, buf, size) + struct proc *p; struct vnode *vp; u_long off; - struct proc *p; caddr_t buf; int size; { @@ -323,11 +288,10 @@ elf_read_from(p, vp, off, buf, size) * so it might be used externally. */ int -elf_load_file(p, path, vcset, entry, ap, last) +elf_load_file(p, path, epp, ap, last) struct proc *p; char *path; - struct exec_vmcmd_set *vcset; - u_long *entry; + struct exec_package *epp; struct elf_args *ap; u_long *last; { @@ -338,30 +302,46 @@ elf_load_file(p, path, vcset, entry, ap, last) u_long phsize; char *bp = NULL; u_long addr = *last; + struct vnode *vp; bp = path; - /* - * 1. open file - * 2. read filehdr - * 3. map text, data, and bss out of it using VM_* - */ - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, p); + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, path, p); if ((error = namei(&nd)) != 0) { return error; } - if ((error = elf_read_from(p, nd.ni_vp, 0, (caddr_t) &eh, - sizeof(eh))) != 0) + vp = nd.ni_vp; + if (vp->v_type != VREG) { + error = EACCES; + goto bad; + } + if ((error = VOP_GETATTR(vp, epp->ep_vap, p->p_ucred, p)) != 0) + goto bad; + if (vp->v_mount->mnt_flag & MNT_NOEXEC) { + error = EACCES; + goto bad; + } + if ((error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p)) != 0) + goto bad; + if ((epp->ep_vap->va_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0) { + error = EACCES; + goto bad; + } + if ((error = VOP_OPEN(vp, FREAD, p->p_ucred, p)) != 0) goto bad; + if ((error = elf_read_from(p, nd.ni_vp, 0, + (caddr_t) &eh, sizeof(eh))) != 0) + goto bad1; + if ((error = elf_check_header(&eh, ET_DYN)) != 0) - goto bad; + goto bad1; phsize = eh.e_phnum * sizeof(Elf32_Phdr); ph = (Elf32_Phdr *) malloc(phsize, M_TEMP, M_WAITOK); if ((error = elf_read_from(p, nd.ni_vp, eh.e_phoff, (caddr_t) ph, phsize)) != 0) - goto bad; + goto bad1; /* * Load all the necessary sections @@ -372,12 +352,12 @@ elf_load_file(p, path, vcset, entry, ap, last) switch (ph[i].p_type) { case PT_LOAD: - elf_load_psection(vcset, nd.ni_vp, &ph[i], &addr, - &size, &prot); + elf_load_psection(&epp->ep_vmcmds, nd.ni_vp, &ph[i], + &addr, &size, &prot); /* If entry is within this section it must be text */ if (eh.e_entry >= ph[i].p_vaddr && eh.e_entry < (ph[i].p_vaddr + size)) { - *entry = addr + eh.e_entry - + epp->ep_entry = addr + eh.e_entry - ELF_ALIGN(ph[i].p_vaddr,ph[i].p_align); ap->arg_interp = addr; } @@ -394,12 +374,14 @@ elf_load_file(p, path, vcset, entry, ap, last) } } +bad1: + VOP_CLOSE(nd.ni_vp, FREAD, p->p_ucred, p); bad: if (ph != NULL) free((char *) ph, M_TEMP); *last = addr; - vrele(nd.ni_vp); + vput(nd.ni_vp); return error; } @@ -542,12 +524,11 @@ exec_elf_makecmds(p, epp) case PT_PHDR: /* Note address of program headers (in text segment) */ phdr = pp->p_vaddr; - break; + break; default: /* - * Not fatal, we don't need to understand everything - * :-) + * Not fatal, we don't need to understand everything :-) */ break; } @@ -565,28 +546,32 @@ exec_elf_makecmds(p, epp) /* * Check if we found a dynamically linked binary and arrange to load - * it's interpreter + * it's interpreter when the exec file is released. */ if (interp[0]) { + char *ip; struct elf_args *ap; + ip = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK); ap = (struct elf_args *) malloc(sizeof(struct elf_args), M_TEMP, M_WAITOK); - if ((error = elf_load_file(p, interp, &epp->ep_vmcmds, - &epp->ep_entry, ap, &pos)) != 0) { - free((char *) ap, M_TEMP); - goto bad; - } - pos += phsize; - ap->arg_phaddr = phdr; + bcopy(interp, ip, MAXPATHLEN); + epp->ep_interp = ip; + epp->ep_interp_pos = pos; + + ap->arg_phaddr = phdr; ap->arg_phentsize = eh->e_phentsize; ap->arg_phnum = eh->e_phnum; ap->arg_entry = eh->e_entry; epp->ep_emul_arg = ap; - } else + epp->ep_entry = eh->e_entry; /* keep check_exec() happy */ + } + else { + epp->ep_interp = NULL; epp->ep_entry = eh->e_entry; + } #ifdef ELF_MAP_PAGE_ZERO /* Dell SVR4 maps page zero, yeuch! */ @@ -603,4 +588,89 @@ bad: kill_vmcmds(&epp->ep_vmcmds); return ENOEXEC; } + +/* + * Phase II of load. It is now safe to load the interpreter. Info collected + * when loading the program is available for setup of the interpreter. + */ +int +exec_elf_fixup(p, epp) + struct proc *p; + struct exec_package *epp; +{ + char *interp; + int error, i; + struct elf_args *ap; + AuxInfo ai[ELF_AUX_ENTRIES], *a; + u_long pos = epp->ep_interp_pos; + + if(epp->ep_interp == 0) { + return 0; + } + + interp = (char *)epp->ep_interp; + ap = (struct elf_args *) epp->ep_emul_arg; + + if ((error = elf_load_file(p, interp, epp, ap, &pos)) != 0) { + free((char *) ap, M_TEMP); + free((char *) interp, M_TEMP); + kill_vmcmds(&epp->ep_vmcmds); + return error; + } + /* + * We have to do this ourselfs... + */ + for (i = 0; i < epp->ep_vmcmds.evs_used && !error; i++) { + struct exec_vmcmd *vcp; + + vcp = &epp->ep_vmcmds.evs_cmds[i]; + error = (*vcp->ev_proc)(p, vcp); + } + kill_vmcmds(&epp->ep_vmcmds); + + /* + * Push extra arguments on the stack needed by dynamically + * linked binaries + */ + if(error == 0) { + a = ai; + + a->au_id = AUX_phdr; + a->au_v = ap->arg_phaddr; + a++; + + a->au_id = AUX_phent; + a->au_v = ap->arg_phentsize; + a++; + + a->au_id = AUX_phnum; + a->au_v = ap->arg_phnum; + a++; + + a->au_id = AUX_pagesz; + a->au_v = NBPG; + a++; + + a->au_id = AUX_base; + a->au_v = ap->arg_interp; + a++; + + a->au_id = AUX_flags; + a->au_v = 0; + a++; + + a->au_id = AUX_entry; + a->au_v = ap->arg_entry; + a++; + + a->au_id = AUX_null; + a->au_v = 0; + a++; + + error = copyout(ai, epp->ep_emul_argp, sizeof ai); + } + free((char *) ap, M_TEMP); + free((char *) interp, M_TEMP); + return error; +} #endif /* NATIVE_EXEC_ELF || EXEC_ELF */ diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index b2ed4ee4607..8bef593ea35 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.15 1996/08/21 09:46:21 deraadt Exp $ */ +/* $OpenBSD: init_main.c,v 1.16 1996/08/31 09:24:08 pefo Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -142,6 +142,7 @@ struct emul emul_native = { 0, copyargs, setregs, + NULL, sigcode, esigcode, }; diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 93674459702..8b6ad57d2e0 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.6 1996/08/25 09:53:45 deraadt Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.7 1996/08/31 09:24:09 pefo Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -162,8 +162,9 @@ check_exec(p, epp) } if (!error) { /* check that entry point is sane */ - if (epp->ep_entry > VM_MAXUSER_ADDRESS) + if (epp->ep_entry > VM_MAXUSER_ADDRESS) { error = ENOEXEC; + } /* check limits */ if ((epp->ep_tsize > MAXTSIZ) || @@ -262,8 +263,9 @@ sys_execve(p, v, retval) pack.ep_flags = 0; /* see if we can run it. */ - if ((error = check_exec(p, &pack)) != 0) + if ((error = check_exec(p, &pack)) != 0) { goto freehdr; + } /* XXX -- THE FOLLOWING SECTION NEEDS MAJOR CLEANUP */ @@ -474,6 +476,10 @@ sys_execve(p, v, retval) vput(pack.ep_vp); /* setup new registers and do misc. setup. */ + if(pack.ep_emul->e_fixup != NULL) { + if((*pack.ep_emul->e_fixup)(p, &pack) != 0) + goto free_pack_abort; + } (*pack.ep_emul->e_setregs)(p, &pack, (u_long) stack, retval); if (p->p_flag & P_TRACED) @@ -520,6 +526,8 @@ exec_abort: VOP_CLOSE(pack.ep_vp, FREAD, cred, p); vput(pack.ep_vp); kmem_free_wakeup(exec_map, (vm_offset_t) argp, NCARGS); + +free_pack_abort: FREE(pack.ep_hdr, M_EXEC); exit1(p, W_EXITCODE(0, SIGABRT)); exit1(p, -1); diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 0b31a22a17c..86612a274f7 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_lookup.c,v 1.2 1996/02/27 07:21:28 niklas Exp $ */ +/* $OpenBSD: ufs_lookup.c,v 1.3 1996/08/31 09:24:10 pefo Exp $ */ /* $NetBSD: ufs_lookup.c,v 1.7 1996/02/09 22:36:06 christos Exp $ */ /* @@ -939,17 +939,18 @@ ufs_dirrewrite(dp, ip, cnp) */ int ufs_dirempty(ip, parentino, cred) - register struct inode *ip; + struct inode *ip; ino_t parentino; struct ucred *cred; { - register off_t off; + off_t off, m; struct dirtemplate dbuf; - register struct direct *dp = (struct direct *)&dbuf; + struct direct *dp = (struct direct *)&dbuf; int error, count, namlen; #define MINDIRSIZ (sizeof (struct dirtemplate) / 2) - for (off = 0; off < ip->i_size; off += dp->d_reclen) { + m = ip->i_size; + for (off = 0; off < m; off += dp->d_reclen) { error = vn_rdwr(UIO_READ, ITOV(ip), (caddr_t)dp, MINDIRSIZ, off, UIO_SYSSPACE, IO_NODELOCKED, cred, &count, (struct proc *)0); /* |