- Use 'p' instead of 'curproc' for the namei lookup as this is what
other image activators use. - Proc locking.
This commit is contained in:
parent
c797833a37
commit
1070c735ff
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user