summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-01-27 00:01:31 +0000
committerjhb <jhb@FreeBSD.org>2001-01-27 00:01:31 +0000
commitb6baa60b1e807d09641c20b2ff1fe838ddebbd3b (patch)
tree81781cbbf3ad98f73e64d11188dfe3084b844e12 /sys/compat
parent0c5b7b7672ac24978496b6d8b72a9f4c74349b64 (diff)
downloadFreeBSD-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/compat')
-rw-r--r--sys/compat/linux/linux_file.c9
-rw-r--r--sys/compat/linux/linux_misc.c22
-rw-r--r--sys/compat/linux/linux_util.c13
-rw-r--r--sys/compat/pecoff/imgact_pecoff.c16
-rw-r--r--sys/compat/svr4/svr4_fcntl.c24
-rw-r--r--sys/compat/svr4/svr4_misc.c18
6 files changed, 18 insertions, 84 deletions
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;
OpenPOWER on IntegriCloud