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 | |
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.
-rw-r--r-- | sys/coda/coda_vfsops.c | 16 | ||||
-rw-r--r-- | sys/compat/linux/linux_file.c | 9 | ||||
-rw-r--r-- | sys/compat/linux/linux_misc.c | 22 | ||||
-rw-r--r-- | sys/compat/linux/linux_util.c | 13 | ||||
-rw-r--r-- | sys/compat/pecoff/imgact_pecoff.c | 16 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_fcntl.c | 24 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_misc.c | 18 | ||||
-rw-r--r-- | sys/dev/ccd/ccd.c | 40 | ||||
-rw-r--r-- | sys/dev/vn/vn.c | 24 | ||||
-rw-r--r-- | sys/fs/cd9660/cd9660_vfsops.c | 17 | ||||
-rw-r--r-- | sys/fs/coda/coda_vfsops.c | 16 | ||||
-rw-r--r-- | sys/fs/hpfs/hpfs_vfsops.c | 10 | ||||
-rw-r--r-- | sys/geom/geom_ccd.c | 40 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_vfsops.c | 27 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_vfsops.c | 27 | ||||
-rw-r--r-- | sys/i386/ibcs2/ibcs2_util.c | 13 | ||||
-rw-r--r-- | sys/i386/ibcs2/imgact_coff.c | 23 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_vfsops.c | 17 | ||||
-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 |
24 files changed, 90 insertions, 448 deletions
diff --git a/sys/coda/coda_vfsops.c b/sys/coda/coda_vfsops.c index 0708181..0496ea5 100644 --- a/sys/coda/coda_vfsops.c +++ b/sys/coda/coda_vfsops.c @@ -292,7 +292,6 @@ coda_root(vfsp, vpp) int error; struct proc *p = curproc; /* XXX - bnoble */ ViceFid VFid; - struct ucred* uc; ENTRY; MARK_ENTRY(CODA_ROOT_STATS); @@ -316,12 +315,7 @@ coda_root(vfsp, vpp) } } - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = venus_root(vftomi(vfsp), uc, p, &VFid); - crfree(uc); + error = venus_root(vftomi(vfsp), p->p_ucred, p, &VFid); if (!error) { /* @@ -447,7 +441,6 @@ coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp) int error; struct proc *p = curproc; /* XXX -mach */ ViceFid VFid; - struct ucred *uc; int vtype; ENTRY; @@ -461,12 +454,7 @@ coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp) return(0); } - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, uc, p, &VFid, &vtype); - crfree(uc); + error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, p->p_ucred, p, &VFid, &vtype); if (error) { CODADEBUG(CODA_VGET, myprintf(("vget error %d\n",error));) diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 1bbe4cc..4736ddc 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -405,7 +405,6 @@ linux_getdents(struct proc *p, struct linux_getdents_args *args) int buflen, error, eofflag, nbytes, justone; u_long *cookies = NULL, *cookiep; int ncookies; - struct ucred *uc; #ifdef DEBUG printf("Linux-emul(%d): getdents(%d, *, %d)\n", @@ -423,13 +422,7 @@ linux_getdents(struct proc *p, struct linux_getdents_args *args) if (vp->v_type != VDIR) return (EINVAL); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = VOP_GETATTR(vp, &va, uc, p); - crfree(uc); - if (error) { + if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) { return error; } diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 10eaa6e..0caff43 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -185,7 +185,6 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) struct vnode *vp; struct exec *a_out; struct vattr attr; - struct ucred *uc; vm_offset_t vmaddr; unsigned long file_offset; vm_offset_t buffer; @@ -237,21 +236,14 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) /* * Executable? */ - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = VOP_GETATTR(vp, &attr, uc, p); - if (error) { - crfree(uc); + error = VOP_GETATTR(vp, &attr, p->p_ucred, p); + if (error) goto cleanup; - } if ((vp->v_mount->mnt_flag & MNT_NOEXEC) || ((attr.va_mode & 0111) == 0) || (attr.va_type != VREG)) { error = ENOEXEC; - crfree(uc); goto cleanup; } @@ -260,21 +252,17 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args) */ if (attr.va_size == 0) { error = ENOEXEC; - crfree(uc); goto cleanup; } /* * Can we access it? */ - error = VOP_ACCESS(vp, VEXEC, uc, p); - if (error) { - crfree(uc); + error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + if (error) goto cleanup; - } - error = VOP_OPEN(vp, FREAD, uc, p); - crfree(uc); + error = VOP_OPEN(vp, FREAD, p->p_ucred, p); if (error) goto cleanup; diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c index f4fe8d7..6399805 100644 --- a/sys/compat/linux/linux_util.c +++ b/sys/compat/linux/linux_util.c @@ -62,7 +62,6 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) struct nameidata ndroot; struct vattr vat; struct vattr vatroot; - struct ucred *uc; int error; char *ptr, *buf, *cp; size_t sz, len; @@ -141,18 +140,12 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) return error; } - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - if ((error = VOP_GETATTR(nd.ni_vp, &vat, uc, p)) != 0) { - crfree(uc); + if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) { goto bad; } - error = VOP_GETATTR(ndroot.ni_vp, &vatroot, uc, p); - crfree(uc); - if (error != 0) { + if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) + != 0) { goto bad; } diff --git a/sys/compat/pecoff/imgact_pecoff.c b/sys/compat/pecoff/imgact_pecoff.c index 88c3342..6dff6ba 100644 --- a/sys/compat/pecoff/imgact_pecoff.c +++ b/sys/compat/pecoff/imgact_pecoff.c @@ -162,7 +162,7 @@ static int pecoff_coredump(register struct proc * p, 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; #ifdef PECOFF_DEBUG @@ -184,10 +184,6 @@ pecoff_coredump(register struct proc * p, register struct vnode * vp, ent = &map->header; printf("%p %p %p\n", ent, ent->prev, ent->next); #endif - 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, @@ -199,7 +195,6 @@ pecoff_coredump(register struct proc * p, register struct vnode * vp, 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); } @@ -605,15 +600,10 @@ pecoff_read_from(p, vp, pos, buf, siz) { int error; size_t resid; - struct ucred *uc; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); error = vn_rdwr(UIO_READ, vp, buf, siz, pos, - UIO_SYSSPACE, IO_NODELOCKED, uc, &resid, p); - crfree(uc); + UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, + &resid, p); if (error) return error; diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c index 3b8adad..c2b865a 100644 --- a/sys/compat/svr4/svr4_fcntl.c +++ b/sys/compat/svr4/svr4_fcntl.c @@ -249,7 +249,6 @@ fd_revoke(p, fd) struct vnode *vp; struct mount *mp; struct vattr vattr; - struct ucred *uc; int error, *retval; retval = p->p_retval; @@ -266,20 +265,12 @@ fd_revoke(p, fd) goto out; } - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - if ((error = VOP_GETATTR(vp, &vattr, uc, p)) != 0) { - crfree(uc); + if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) goto out; - } - if (uc->cr_uid != vattr.va_uid && (error = suser(p)) != 0) { - crfree(uc); + if (p->p_ucred->cr_uid != vattr.va_uid && + (error = suser(p)) != 0) goto out; - } - crfree(uc); if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto out; @@ -303,7 +294,6 @@ fd_truncate(p, fd, flp) off_t start, length; struct vnode *vp; struct vattr vattr; - struct ucred *uc; int error, *retval; struct ftruncate_args ft; @@ -319,13 +309,7 @@ fd_truncate(p, fd, flp) if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) return ESPIPE; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = VOP_GETATTR(vp, &vattr, uc, p); - crfree(uc); - if (error != 0) + if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) return error; length = vattr.va_size; diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index 62d0da9..b976c2d 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -250,7 +250,6 @@ svr4_sys_getdents64(p, uap) struct uio auio; struct iovec aiov; struct vattr va; - struct ucred *uc; off_t off; struct svr4_dirent64 svr4_dirent; int buflen, error, eofflag, nbytes, justone; @@ -271,13 +270,7 @@ svr4_sys_getdents64(p, uap) if (vp->v_type != VDIR) return (EINVAL); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = VOP_GETATTR(vp, &va, uc, p); - crfree(uc); - if (error != 0) { + if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) { return error; } @@ -599,7 +592,6 @@ svr4_sys_fchroot(p, uap) struct filedesc *fdp = p->p_fd; struct vnode *vp; struct file *fp; - struct ucred *uc; int error; if ((error = suser(p)) != 0) @@ -610,14 +602,8 @@ svr4_sys_fchroot(p, uap) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); if (vp->v_type != VDIR) error = ENOTDIR; - else { - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); + else error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); - crfree(uc); - } VOP_UNLOCK(vp, 0, p); if (error) return error; diff --git a/sys/dev/ccd/ccd.c b/sys/dev/ccd/ccd.c index 69098b9..cdd07ce 100644 --- a/sys/dev/ccd/ccd.c +++ b/sys/dev/ccd/ccd.c @@ -380,7 +380,6 @@ ccdinit(ccd, cpaths, p) size_t size; int ix; struct vnode *vp; - struct ucred *uc; size_t minsize; int maxsecsize; struct partinfo dpart; @@ -407,10 +406,6 @@ ccdinit(ccd, cpaths, p) */ maxsecsize = 0; minsize = 0; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); for (ix = 0; ix < cs->sc_nccdisks; ix++) { vp = ccd->ccd_vpp[ix]; ci = &cs->sc_cinfo[ix]; @@ -438,7 +433,7 @@ ccdinit(ccd, cpaths, p) * Get partition information for the component. */ if ((error = VOP_IOCTL(vp, DIOCGPART, (caddr_t)&dpart, - FREAD, uc, p)) != 0) { + FREAD, p->p_ucred, p)) != 0) { #ifdef DEBUG if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) printf("ccd%d: %s: ioctl failed, error = %d\n", @@ -484,7 +479,6 @@ ccdinit(ccd, cpaths, p) ci->ci_size = size; cs->sc_size += size; } - crfree(uc); /* * Don't allow the interleave to be smaller than @@ -572,7 +566,6 @@ ccdinit(ccd, cpaths, p) cs->sc_unit = ccd->ccd_unit; return (0); fail: - crfree(uc); while (ci > cs->sc_cinfo) { ci--; free(ci->ci_path, M_DEVBUF); @@ -1272,7 +1265,6 @@ ccdioctl(dev, cmd, data, flag, p) struct ccddevice ccd; char **cpp; struct vnode **vpp; - struct ucred *uc; if (unit >= numccd) return (ENXIO); @@ -1344,17 +1336,12 @@ ccdioctl(dev, cmd, data, flag, p) printf("ccdioctl: lookedup = %d\n", lookedup); #endif if ((error = ccdlookup(cpp[i], p, &vpp[i])) != 0) { - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); for (j = 0; j < lookedup; ++j) (void)vn_close(vpp[j], FREAD|FWRITE, - uc, p); + p->p_ucred, p); free(vpp, M_DEVBUF); free(cpp, M_DEVBUF); ccdunlock(cs); - crfree(uc); return (error); } ++lookedup; @@ -1367,17 +1354,13 @@ ccdioctl(dev, cmd, data, flag, p) * Initialize the ccd. Fills in the softc for us. */ if ((error = ccdinit(&ccd, cpp, p)) != 0) { - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); for (j = 0; j < lookedup; ++j) - (void)vn_close(vpp[j], FREAD|FWRITE, uc, p); + (void)vn_close(vpp[j], FREAD|FWRITE, + p->p_ucred, p); bzero(&ccd_softc[unit], sizeof(struct ccd_softc)); free(vpp, M_DEVBUF); free(cpp, M_DEVBUF); ccdunlock(cs); - crfree(uc); return (error); } @@ -1417,10 +1400,6 @@ ccdioctl(dev, cmd, data, flag, p) */ /* Close the components and free their pathnames. */ - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); for (i = 0; i < cs->sc_nccdisks; ++i) { /* * XXX: this close could potentially fail and @@ -1433,10 +1412,9 @@ ccdioctl(dev, cmd, data, flag, p) cs->sc_cinfo[i].ci_vp); #endif (void)vn_close(cs->sc_cinfo[i].ci_vp, FREAD|FWRITE, - uc, p); + p->p_ucred, p); free(cs->sc_cinfo[i].ci_path, M_DEVBUF); } - crfree(uc); /* Free interleave index. */ for (i = 0; cs->sc_itable[i].ii_ndisk; ++i) @@ -1581,7 +1559,6 @@ ccdlookup(path, p, vpp) { struct nameidata nd; struct vnode *vp; - struct ucred *uc; int error, flags; NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, path, p); @@ -1616,12 +1593,7 @@ bad: VOP_UNLOCK(vp, 0, p); NDFREE(&nd, NDF_ONLY_PNBUF); /* vn_close does vrele() for vp */ - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - (void)vn_close(vp, FREAD|FWRITE, uc, p); - crfree(uc); + (void)vn_close(vp, FREAD|FWRITE, p->p_ucred, p); return (error); } diff --git a/sys/dev/vn/vn.c b/sys/dev/vn/vn.c index d11b6ed..570b926 100644 --- a/sys/dev/vn/vn.c +++ b/sys/dev/vn/vn.c @@ -562,7 +562,6 @@ vniocattach_file(vn, vio, dev, flag, p) struct proc *p; { struct vattr vattr; - struct ucred *uc; struct nameidata nd; int error, flags; @@ -579,15 +578,10 @@ vniocattach_file(vn, vio, dev, flag, p) return (error); } NDFREE(&nd, NDF_ONLY_PNBUF); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); if (nd.ni_vp->v_type != VREG || - (error = VOP_GETATTR(nd.ni_vp, &vattr, uc, p))) { + (error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p))) { VOP_UNLOCK(nd.ni_vp, 0, p); - (void) vn_close(nd.ni_vp, flags, uc, p); - crfree(uc); + (void) vn_close(nd.ni_vp, flags, p->p_ucred, p); return (error ? error : EINVAL); } VOP_UNLOCK(nd.ni_vp, 0, p); @@ -602,13 +596,11 @@ vniocattach_file(vn, vio, dev, flag, p) vn->sc_size = (quad_t)vio->vn_size * PAGE_SIZE / vn->sc_secsize; else vn->sc_size = vattr.va_size / vn->sc_secsize; - error = vnsetcred(vn, uc); + error = vnsetcred(vn, p->p_ucred); if (error) { - (void) vn_close(nd.ni_vp, flags, uc, p); - crfree(uc); + (void) vn_close(nd.ni_vp, flags, p->p_ucred, p); return(error); } - crfree(uc); vn->sc_flags |= VNF_INITED; if (flags == FREAD) vn->sc_flags |= VNF_READONLY; @@ -635,7 +627,6 @@ vniocattach_swap(vn, vio, dev, flag, p) struct proc *p; { int error; - struct ucred *uc; /* * Range check. Disallow negative sizes or any size less then the @@ -667,12 +658,7 @@ vniocattach_swap(vn, vio, dev, flag, p) } } vn->sc_flags |= VNF_INITED; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = vnsetcred(vn, uc); - crfree(uc); + error = vnsetcred(vn, p->p_ucred); if (error == 0) { IFOPT(vn, VN_FOLLOW) { printf("vnioctl: SET vp %p size %x\n", diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index cd58e6d..aaefb78 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -183,7 +183,6 @@ cd9660_mount(mp, path, data, ndp, p) { struct vnode *devvp; struct iso_args args; - struct ucred *uc; size_t size; int error; mode_t accessmode; @@ -228,12 +227,7 @@ cd9660_mount(mp, path, data, ndp, p) */ accessmode = VREAD; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = VOP_ACCESS(devvp, accessmode, uc, p); - crfree(uc); + error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p); if (error) error = suser(p); if (error) { @@ -277,7 +271,6 @@ iso_mountfs(devvp, mp, p, argp) register struct iso_mnt *isomp = (struct iso_mnt *)0; struct buf *bp = NULL; struct buf *pribp = NULL, *supbp = NULL; - struct ucred *uc; dev_t dev = devvp->v_rdev; int error = EINVAL; int needclose = 0; @@ -305,13 +298,7 @@ iso_mountfs(devvp, mp, p, argp) return error; if (vcount(devvp) > 1 && devvp != rootvp) return EBUSY; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0); - crfree(uc); - if (error) + if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0))) return (error); vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); diff --git a/sys/fs/coda/coda_vfsops.c b/sys/fs/coda/coda_vfsops.c index 0708181..0496ea5 100644 --- a/sys/fs/coda/coda_vfsops.c +++ b/sys/fs/coda/coda_vfsops.c @@ -292,7 +292,6 @@ coda_root(vfsp, vpp) int error; struct proc *p = curproc; /* XXX - bnoble */ ViceFid VFid; - struct ucred* uc; ENTRY; MARK_ENTRY(CODA_ROOT_STATS); @@ -316,12 +315,7 @@ coda_root(vfsp, vpp) } } - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = venus_root(vftomi(vfsp), uc, p, &VFid); - crfree(uc); + error = venus_root(vftomi(vfsp), p->p_ucred, p, &VFid); if (!error) { /* @@ -447,7 +441,6 @@ coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp) int error; struct proc *p = curproc; /* XXX -mach */ ViceFid VFid; - struct ucred *uc; int vtype; ENTRY; @@ -461,12 +454,7 @@ coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp) return(0); } - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, uc, p, &VFid, &vtype); - crfree(uc); + error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, p->p_ucred, p, &VFid, &vtype); if (error) { CODADEBUG(CODA_VGET, myprintf(("vget error %d\n",error));) diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c index 5b8d9bb..1581851 100644 --- a/sys/fs/hpfs/hpfs_vfsops.c +++ b/sys/fs/hpfs/hpfs_vfsops.c @@ -331,9 +331,6 @@ hpfs_mountfs(devvp, mp, argsp, p) struct hpfsmount *hpmp; struct buf *bp = NULL; struct vnode *vp; -#if defined(__FreeBSD__) - struct ucred *uc; -#endif dev_t dev = devvp->v_rdev; dprintf(("hpfs_mountfs():\n")); @@ -356,12 +353,7 @@ hpfs_mountfs(devvp, mp, argsp, p) #if defined(__FreeBSD__) VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = vinvalbuf(devvp, V_SAVE, uc, p, 0, 0); - crfree(uc); + error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0); VOP__UNLOCK(devvp, 0, p); #else error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0); diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c index 69098b9..cdd07ce 100644 --- a/sys/geom/geom_ccd.c +++ b/sys/geom/geom_ccd.c @@ -380,7 +380,6 @@ ccdinit(ccd, cpaths, p) size_t size; int ix; struct vnode *vp; - struct ucred *uc; size_t minsize; int maxsecsize; struct partinfo dpart; @@ -407,10 +406,6 @@ ccdinit(ccd, cpaths, p) */ maxsecsize = 0; minsize = 0; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); for (ix = 0; ix < cs->sc_nccdisks; ix++) { vp = ccd->ccd_vpp[ix]; ci = &cs->sc_cinfo[ix]; @@ -438,7 +433,7 @@ ccdinit(ccd, cpaths, p) * Get partition information for the component. */ if ((error = VOP_IOCTL(vp, DIOCGPART, (caddr_t)&dpart, - FREAD, uc, p)) != 0) { + FREAD, p->p_ucred, p)) != 0) { #ifdef DEBUG if (ccddebug & (CCDB_FOLLOW|CCDB_INIT)) printf("ccd%d: %s: ioctl failed, error = %d\n", @@ -484,7 +479,6 @@ ccdinit(ccd, cpaths, p) ci->ci_size = size; cs->sc_size += size; } - crfree(uc); /* * Don't allow the interleave to be smaller than @@ -572,7 +566,6 @@ ccdinit(ccd, cpaths, p) cs->sc_unit = ccd->ccd_unit; return (0); fail: - crfree(uc); while (ci > cs->sc_cinfo) { ci--; free(ci->ci_path, M_DEVBUF); @@ -1272,7 +1265,6 @@ ccdioctl(dev, cmd, data, flag, p) struct ccddevice ccd; char **cpp; struct vnode **vpp; - struct ucred *uc; if (unit >= numccd) return (ENXIO); @@ -1344,17 +1336,12 @@ ccdioctl(dev, cmd, data, flag, p) printf("ccdioctl: lookedup = %d\n", lookedup); #endif if ((error = ccdlookup(cpp[i], p, &vpp[i])) != 0) { - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); for (j = 0; j < lookedup; ++j) (void)vn_close(vpp[j], FREAD|FWRITE, - uc, p); + p->p_ucred, p); free(vpp, M_DEVBUF); free(cpp, M_DEVBUF); ccdunlock(cs); - crfree(uc); return (error); } ++lookedup; @@ -1367,17 +1354,13 @@ ccdioctl(dev, cmd, data, flag, p) * Initialize the ccd. Fills in the softc for us. */ if ((error = ccdinit(&ccd, cpp, p)) != 0) { - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); for (j = 0; j < lookedup; ++j) - (void)vn_close(vpp[j], FREAD|FWRITE, uc, p); + (void)vn_close(vpp[j], FREAD|FWRITE, + p->p_ucred, p); bzero(&ccd_softc[unit], sizeof(struct ccd_softc)); free(vpp, M_DEVBUF); free(cpp, M_DEVBUF); ccdunlock(cs); - crfree(uc); return (error); } @@ -1417,10 +1400,6 @@ ccdioctl(dev, cmd, data, flag, p) */ /* Close the components and free their pathnames. */ - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); for (i = 0; i < cs->sc_nccdisks; ++i) { /* * XXX: this close could potentially fail and @@ -1433,10 +1412,9 @@ ccdioctl(dev, cmd, data, flag, p) cs->sc_cinfo[i].ci_vp); #endif (void)vn_close(cs->sc_cinfo[i].ci_vp, FREAD|FWRITE, - uc, p); + p->p_ucred, p); free(cs->sc_cinfo[i].ci_path, M_DEVBUF); } - crfree(uc); /* Free interleave index. */ for (i = 0; cs->sc_itable[i].ii_ndisk; ++i) @@ -1581,7 +1559,6 @@ ccdlookup(path, p, vpp) { struct nameidata nd; struct vnode *vp; - struct ucred *uc; int error, flags; NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, path, p); @@ -1616,12 +1593,7 @@ bad: VOP_UNLOCK(vp, 0, p); NDFREE(&nd, NDF_ONLY_PNBUF); /* vn_close does vrele() for vp */ - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - (void)vn_close(vp, FREAD|FWRITE, uc, p); - crfree(uc); + (void)vn_close(vp, FREAD|FWRITE, p->p_ucred, p); return (error); } diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index e7dfbf2..7119096 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -187,7 +187,6 @@ ext2_mount(mp, path, data, ndp, p) struct vnode *devvp; struct ufs_args args; struct ufsmount *ump = 0; - struct ucred *uc; register struct ext2_sb_info *fs; size_t size; int error, flags; @@ -232,17 +231,11 @@ ext2_mount(mp, path, data, ndp, p) */ if (suser(p)) { vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); if ((error = VOP_ACCESS(devvp, VREAD | VWRITE, - uc, p)) != 0) { - crfree(uc); + p->p_ucred, p)) != 0) { VOP_UNLOCK(devvp, 0, p); return (error); } - crfree(uc); VOP_UNLOCK(devvp, 0, p); } @@ -294,16 +287,10 @@ ext2_mount(mp, path, data, ndp, p) if ((mp->mnt_flag & MNT_RDONLY) == 0) accessmode |= VWRITE; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - if ((error = VOP_ACCESS(devvp, accessmode, uc, p)) != 0) { - crfree(uc); + if ((error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p)) != 0) { vput(devvp); return (error); } - crfree(uc); VOP_UNLOCK(devvp, 0, p); } @@ -629,7 +616,6 @@ ext2_mountfs(devvp, mp, p) { register struct ufsmount *ump; struct buf *bp; - struct ucred *uc; register struct ext2_sb_info *fs; struct ext2_super_block * es; dev_t dev = devvp->v_rdev; @@ -648,15 +634,8 @@ ext2_mountfs(devvp, mp, p) return (error); if (vcount(devvp) > 1 && devvp != rootvp) return (EBUSY); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - if ((error = vinvalbuf(devvp, V_SAVE, uc, p, 0, 0)) != 0) { - crfree(uc); + if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)) != 0) return (error); - } - crfree(uc); #ifdef READONLY /* turn on this to force it to be read-only */ mp->mnt_flag |= MNT_RDONLY; diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index e7dfbf2..7119096 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -187,7 +187,6 @@ ext2_mount(mp, path, data, ndp, p) struct vnode *devvp; struct ufs_args args; struct ufsmount *ump = 0; - struct ucred *uc; register struct ext2_sb_info *fs; size_t size; int error, flags; @@ -232,17 +231,11 @@ ext2_mount(mp, path, data, ndp, p) */ if (suser(p)) { vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); if ((error = VOP_ACCESS(devvp, VREAD | VWRITE, - uc, p)) != 0) { - crfree(uc); + p->p_ucred, p)) != 0) { VOP_UNLOCK(devvp, 0, p); return (error); } - crfree(uc); VOP_UNLOCK(devvp, 0, p); } @@ -294,16 +287,10 @@ ext2_mount(mp, path, data, ndp, p) if ((mp->mnt_flag & MNT_RDONLY) == 0) accessmode |= VWRITE; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - if ((error = VOP_ACCESS(devvp, accessmode, uc, p)) != 0) { - crfree(uc); + if ((error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p)) != 0) { vput(devvp); return (error); } - crfree(uc); VOP_UNLOCK(devvp, 0, p); } @@ -629,7 +616,6 @@ ext2_mountfs(devvp, mp, p) { register struct ufsmount *ump; struct buf *bp; - struct ucred *uc; register struct ext2_sb_info *fs; struct ext2_super_block * es; dev_t dev = devvp->v_rdev; @@ -648,15 +634,8 @@ ext2_mountfs(devvp, mp, p) return (error); if (vcount(devvp) > 1 && devvp != rootvp) return (EBUSY); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - if ((error = vinvalbuf(devvp, V_SAVE, uc, p, 0, 0)) != 0) { - crfree(uc); + if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)) != 0) return (error); - } - crfree(uc); #ifdef READONLY /* turn on this to force it to be read-only */ mp->mnt_flag |= MNT_RDONLY; diff --git a/sys/i386/ibcs2/ibcs2_util.c b/sys/i386/ibcs2/ibcs2_util.c index 1d710be..0a361fd 100644 --- a/sys/i386/ibcs2/ibcs2_util.c +++ b/sys/i386/ibcs2/ibcs2_util.c @@ -62,7 +62,6 @@ ibcs2_emul_find(p, sgp, prefix, path, pbuf, cflag) struct nameidata ndroot; struct vattr vat; struct vattr vatroot; - struct ucred *uc; int error; char *ptr, *buf, *cp; size_t sz, len; @@ -141,20 +140,14 @@ ibcs2_emul_find(p, sgp, prefix, path, pbuf, cflag) return error; } - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - if ((error = VOP_GETATTR(nd.ni_vp, &vat, uc, p)) != 0) { - crfree(uc); + if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) { goto done; } - if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, uc, p)) != 0) { - crfree(uc); + if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) + != 0) { goto done; } - crfree(uc); if (vat.va_fsid == vatroot.va_fsid && vat.va_fileid == vatroot.va_fileid) { diff --git a/sys/i386/ibcs2/imgact_coff.c b/sys/i386/ibcs2/imgact_coff.c index 066648b..e7cb544 100644 --- a/sys/i386/ibcs2/imgact_coff.c +++ b/sys/i386/ibcs2/imgact_coff.c @@ -156,7 +156,6 @@ 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; @@ -182,38 +181,24 @@ coff_load_file(struct proc *p, char *name) goto fail; } - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - if ((error = VOP_GETATTR(vp, &attr, uc, p)) != 0) { - crfree(uc); + if ((error = VOP_GETATTR(vp, &attr, p->p_ucred, p)) != 0) goto fail; - } if ((vp->v_mount->mnt_flag & MNT_NOEXEC) || ((attr.va_mode & 0111) == 0) - || (attr.va_type != VREG)) { - crfree(uc); + || (attr.va_type != VREG)) goto fail; - } if (attr.va_size == 0) { error = ENOEXEC; - crfree(uc); goto fail; } - if ((error = VOP_ACCESS(vp, VEXEC, uc, p)) != 0) { - crfree(uc); + if ((error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p)) != 0) goto fail; - } - if ((error = VOP_OPEN(vp, FREAD, uc, p)) != 0) { - crfree(uc); + if ((error = VOP_OPEN(vp, FREAD, p->p_ucred, p)) != 0) goto fail; - } - crfree(uc); /* * Lose the lock on the vnode. It's no longer needed, and must not diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index cd58e6d..aaefb78 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -183,7 +183,6 @@ cd9660_mount(mp, path, data, ndp, p) { struct vnode *devvp; struct iso_args args; - struct ucred *uc; size_t size; int error; mode_t accessmode; @@ -228,12 +227,7 @@ cd9660_mount(mp, path, data, ndp, p) */ accessmode = VREAD; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = VOP_ACCESS(devvp, accessmode, uc, p); - crfree(uc); + error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p); if (error) error = suser(p); if (error) { @@ -277,7 +271,6 @@ iso_mountfs(devvp, mp, p, argp) register struct iso_mnt *isomp = (struct iso_mnt *)0; struct buf *bp = NULL; struct buf *pribp = NULL, *supbp = NULL; - struct ucred *uc; dev_t dev = devvp->v_rdev; int error = EINVAL; int needclose = 0; @@ -305,13 +298,7 @@ iso_mountfs(devvp, mp, p, argp) return error; if (vcount(devvp) > 1 && devvp != rootvp) return EBUSY; - PROC_LOCK(p); - uc = p->p_ucred; - crhold(uc); - PROC_UNLOCK(p); - error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0); - crfree(uc); - if (error) + if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0))) return (error); vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); 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); } |