From 1070c735ff8968665e70df1dd5acbb09a2d4c100 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 23 Jan 2001 23:59:30 +0000 Subject: [PATCH] - Use 'p' instead of 'curproc' for the namei lookup as this is what other image activators use. - Proc locking. --- sys/i386/ibcs2/imgact_coff.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/sys/i386/ibcs2/imgact_coff.c b/sys/i386/ibcs2/imgact_coff.c index 16dbd6e47ec..066648b4ca3 100644 --- a/sys/i386/ibcs2/imgact_coff.c +++ b/sys/i386/ibcs2/imgact_coff.c @@ -156,6 +156,7 @@ coff_load_file(struct proc *p, char *name) struct nameidata nd; struct vnode *vp; struct vattr attr; + struct ucred *uc; struct filehdr *fhdr; struct aouthdr *ahdr; struct scnhdr *scns; @@ -166,8 +167,7 @@ coff_load_file(struct proc *p, char *name) unsigned long bss_size = 0; int i; - /* XXX use of 'curproc' should be 'p'?*/ - NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, name, curproc); + NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, name, p); error = namei(&nd); if (error) @@ -182,24 +182,38 @@ coff_load_file(struct proc *p, char *name) goto fail; } - if ((error = VOP_GETATTR(vp, &attr, p->p_ucred, p)) != 0) + PROC_LOCK(p); + uc = p->p_ucred; + crhold(uc); + PROC_UNLOCK(p); + if ((error = VOP_GETATTR(vp, &attr, uc, p)) != 0) { + crfree(uc); goto fail; + } if ((vp->v_mount->mnt_flag & MNT_NOEXEC) || ((attr.va_mode & 0111) == 0) - || (attr.va_type != VREG)) + || (attr.va_type != VREG)) { + crfree(uc); goto fail; + } if (attr.va_size == 0) { error = ENOEXEC; + crfree(uc); goto fail; } - if ((error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p)) != 0) + if ((error = VOP_ACCESS(vp, VEXEC, uc, p)) != 0) { + crfree(uc); goto fail; + } - if ((error = VOP_OPEN(vp, FREAD, p->p_ucred, p)) != 0) + if ((error = VOP_OPEN(vp, FREAD, uc, p)) != 0) { + crfree(uc); goto fail; + } + crfree(uc); /* * Lose the lock on the vnode. It's no longer needed, and must not