diff options
author | jhb <jhb@FreeBSD.org> | 2001-01-27 00:01:31 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-01-27 00:01:31 +0000 |
commit | b6baa60b1e807d09641c20b2ff1fe838ddebbd3b (patch) | |
tree | 81781cbbf3ad98f73e64d11188dfe3084b844e12 /sys/kern | |
parent | 0c5b7b7672ac24978496b6d8b72a9f4c74349b64 (diff) | |
download | FreeBSD-src-b6baa60b1e807d09641c20b2ff1fe838ddebbd3b.zip FreeBSD-src-b6baa60b1e807d09641c20b2ff1fe838ddebbd3b.tar.gz |
Back out proc locking to protect p_ucred for obtaining additional
references along with the actual obtaining of additional references.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/imgact_aout.c | 7 | ||||
-rw-r--r-- | sys/kern/imgact_elf.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_acct.c | 32 | ||||
-rw-r--r-- | sys/kern/kern_acl.c | 40 | ||||
-rw-r--r-- | sys/kern/subr_acl_posix1e.c | 40 | ||||
-rw-r--r-- | sys/kern/vfs_acl.c | 40 |
6 files changed, 33 insertions, 133 deletions
diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c index ff315f5..32f2630 100644 --- a/sys/kern/imgact_aout.c +++ b/sys/kern/imgact_aout.c @@ -249,17 +249,13 @@ aout_coredump(p, vp, limit) register struct vnode *vp; off_t limit; { - register struct ucred *cred; + register struct ucred *cred = p->p_ucred; register struct vmspace *vm = p->p_vmspace; int error; if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >= limit) return (EFAULT); fill_kinfo_proc(p, &p->p_addr->u_kproc); - PROC_LOCK(p); - cred = p->p_ucred; - crhold(cred); - PROC_UNLOCK(p); error = cpu_coredump(p, vp, cred); if (error == 0) error = vn_rdwr(UIO_WRITE, vp, vm->vm_daddr, @@ -271,7 +267,6 @@ aout_coredump(p, vp, limit) round_page(ctob(vm->vm_ssize)), (off_t)ctob(UPAGES) + ctob(vm->vm_dsize), UIO_USERSPACE, IO_NODELOCKED|IO_UNIT, cred, (int *) NULL, p); - crfree(cred); return (error); } diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index c3d8cf7..96db3b3 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -722,7 +722,7 @@ elf_coredump(p, vp, limit) register struct vnode *vp; off_t limit; { - register struct ucred *cred; + register struct ucred *cred = p->p_ucred; int error = 0; struct sseg_closure seginfo; void *hdr; @@ -754,10 +754,6 @@ elf_coredump(p, vp, limit) if (hdr == NULL) { return EINVAL; } - PROC_LOCK(p); - cred = p->p_ucred; - crhold(cred); - PROC_UNLOCK(p); error = elf_corehdr(p, vp, cred, seginfo.count, hdr, hdrsize); /* Write the contents of all of the writable segments. */ @@ -778,7 +774,6 @@ elf_coredump(p, vp, limit) php++; } } - crfree(cred); free(hdr, M_TEMP); return error; diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index 9ec0f05..9220e57 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -114,7 +114,6 @@ acct(a1, uap) } */ *uap; { struct proc *p = curproc; /* XXX */ - struct ucred *uc; struct nameidata nd; int error, flags; @@ -137,12 +136,7 @@ acct(a1, uap) NDFREE(&nd, NDF_ONLY_PNBUF); VOP_UNLOCK(nd.ni_vp, 0, p); if (nd.ni_vp->v_type != VREG) { - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - vn_close(nd.ni_vp, FWRITE, uc, p); - crfree(uc); + vn_close(nd.ni_vp, FWRITE, p->p_ucred, p); return (EACCES); } } @@ -153,13 +147,8 @@ acct(a1, uap) */ if (acctp != NULLVP || savacctp != NULLVP) { callout_stop(&acctwatch_callout); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); error = vn_close((acctp != NULLVP ? acctp : savacctp), FWRITE, - uc, p); - crfree(uc); + p->p_ucred, p); acctp = savacctp = NULLVP; } if (SCARG(uap, path) == NULL) @@ -187,10 +176,9 @@ acct_process(p) struct proc *p; { struct acct acct; - struct ucred *uc; struct rusage *r; struct timeval ut, st, tmp; - int t, error; + int t; struct vnode *vp; /* If accounting isn't enabled, don't bother */ @@ -231,7 +219,6 @@ acct_process(p) /* (5) The number of disk I/O operations done */ acct.ac_io = encode_comp_t(r->ru_inblock + r->ru_oublock, 0); - PROC_LOCK(p); /* (6) The UID and GID of the process */ acct.ac_uid = p->p_cred->p_ruid; acct.ac_gid = p->p_cred->p_rgid; @@ -248,7 +235,6 @@ acct_process(p) /* * Eliminate any file size rlimit. */ - mtx_assert(&Giant, MA_OWNED); if (p->p_limit->p_refcnt > 1 && (p->p_limit->p_lflags & PL_SHAREMOD) == 0) { p->p_limit->p_refcnt--; @@ -259,14 +245,10 @@ acct_process(p) /* * Write the accounting information to the file. */ - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - VOP_LEASE(vp, p, uc, LEASE_WRITE); - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&acct, sizeof (acct), - (off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, uc, (int *)0, p); - crfree(uc); - return (error); + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + return (vn_rdwr(UIO_WRITE, vp, (caddr_t)&acct, sizeof (acct), + (off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, p->p_ucred, + (int *)0, p)); } /* diff --git a/sys/kern/kern_acl.c b/sys/kern/kern_acl.c index 8d0c6c7..0e9fc40 100644 --- a/sys/kern/kern_acl.c +++ b/sys/kern/kern_acl.c @@ -72,22 +72,16 @@ vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernacl; - struct ucred *uc; int error; error = copyin(aclp, &inkernacl, sizeof(struct acl)); if (error) return(error); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - VOP_LEASE(vp, p, uc, LEASE_WRITE); + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, type, &inkernacl, uc, p); + error = VOP_SETACL(vp, type, &inkernacl, p->p_ucred, p); VOP_UNLOCK(vp, 0, p); - crfree(uc); - return (error); + return(error); } /* @@ -98,18 +92,12 @@ vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; - struct ucred *uc; int error; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - VOP_LEASE(vp, p, uc, LEASE_WRITE); + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_GETACL(vp, type, &inkernelacl, uc, p); + error = VOP_GETACL(vp, type, &inkernelacl, p->p_ucred, p); VOP_UNLOCK(vp, 0, p); - crfree(uc); if (error == 0) error = copyout(&inkernelacl, aclp, sizeof(struct acl)); return (error); @@ -121,18 +109,12 @@ vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, static int vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type) { - struct ucred *uc; int error; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - VOP_LEASE(vp, p, uc, LEASE_WRITE); + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, uc, p); + error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, p->p_ucred, p); VOP_UNLOCK(vp, 0, p); - crfree(uc); return (error); } @@ -144,18 +126,12 @@ vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; - struct ucred *uc; int error; error = copyin(aclp, &inkernelacl, sizeof(struct acl)); if (error) return(error); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = VOP_ACLCHECK(vp, type, &inkernelacl, uc, p); - crfree(uc); + error = VOP_ACLCHECK(vp, type, &inkernelacl, p->p_ucred, p); return (error); } diff --git a/sys/kern/subr_acl_posix1e.c b/sys/kern/subr_acl_posix1e.c index 8d0c6c7..0e9fc40 100644 --- a/sys/kern/subr_acl_posix1e.c +++ b/sys/kern/subr_acl_posix1e.c @@ -72,22 +72,16 @@ vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernacl; - struct ucred *uc; int error; error = copyin(aclp, &inkernacl, sizeof(struct acl)); if (error) return(error); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - VOP_LEASE(vp, p, uc, LEASE_WRITE); + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, type, &inkernacl, uc, p); + error = VOP_SETACL(vp, type, &inkernacl, p->p_ucred, p); VOP_UNLOCK(vp, 0, p); - crfree(uc); - return (error); + return(error); } /* @@ -98,18 +92,12 @@ vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; - struct ucred *uc; int error; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - VOP_LEASE(vp, p, uc, LEASE_WRITE); + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_GETACL(vp, type, &inkernelacl, uc, p); + error = VOP_GETACL(vp, type, &inkernelacl, p->p_ucred, p); VOP_UNLOCK(vp, 0, p); - crfree(uc); if (error == 0) error = copyout(&inkernelacl, aclp, sizeof(struct acl)); return (error); @@ -121,18 +109,12 @@ vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, static int vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type) { - struct ucred *uc; int error; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - VOP_LEASE(vp, p, uc, LEASE_WRITE); + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, uc, p); + error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, p->p_ucred, p); VOP_UNLOCK(vp, 0, p); - crfree(uc); return (error); } @@ -144,18 +126,12 @@ vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; - struct ucred *uc; int error; error = copyin(aclp, &inkernelacl, sizeof(struct acl)); if (error) return(error); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = VOP_ACLCHECK(vp, type, &inkernelacl, uc, p); - crfree(uc); + error = VOP_ACLCHECK(vp, type, &inkernelacl, p->p_ucred, p); return (error); } diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c index 8d0c6c7..0e9fc40 100644 --- a/sys/kern/vfs_acl.c +++ b/sys/kern/vfs_acl.c @@ -72,22 +72,16 @@ vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernacl; - struct ucred *uc; int error; error = copyin(aclp, &inkernacl, sizeof(struct acl)); if (error) return(error); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - VOP_LEASE(vp, p, uc, LEASE_WRITE); + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, type, &inkernacl, uc, p); + error = VOP_SETACL(vp, type, &inkernacl, p->p_ucred, p); VOP_UNLOCK(vp, 0, p); - crfree(uc); - return (error); + return(error); } /* @@ -98,18 +92,12 @@ vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; - struct ucred *uc; int error; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - VOP_LEASE(vp, p, uc, LEASE_WRITE); + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_GETACL(vp, type, &inkernelacl, uc, p); + error = VOP_GETACL(vp, type, &inkernelacl, p->p_ucred, p); VOP_UNLOCK(vp, 0, p); - crfree(uc); if (error == 0) error = copyout(&inkernelacl, aclp, sizeof(struct acl)); return (error); @@ -121,18 +109,12 @@ vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type, static int vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type) { - struct ucred *uc; int error; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - VOP_LEASE(vp, p, uc, LEASE_WRITE); + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, uc, p); + error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, p->p_ucred, p); VOP_UNLOCK(vp, 0, p); - crfree(uc); return (error); } @@ -144,18 +126,12 @@ vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type, struct acl *aclp) { struct acl inkernelacl; - struct ucred *uc; int error; error = copyin(aclp, &inkernelacl, sizeof(struct acl)); if (error) return(error); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = VOP_ACLCHECK(vp, type, &inkernelacl, uc, p); - crfree(uc); + error = VOP_ACLCHECK(vp, type, &inkernelacl, p->p_ucred, p); return (error); } |