summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_file.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2000-12-15 19:41:27 +0000
committerjhb <jhb@FreeBSD.org>2000-12-15 19:41:27 +0000
commit81c40ecc9ceba6e061fd35e0d08c8c37d3121aee (patch)
tree7e104248a7cb66a32e98b1b0efcd4193e1b3433e /sys/compat/linux/linux_file.c
parente761ef905bfe40800a70e05c7023a3a4acaa364b (diff)
downloadFreeBSD-src-81c40ecc9ceba6e061fd35e0d08c8c37d3121aee.zip
FreeBSD-src-81c40ecc9ceba6e061fd35e0d08c8c37d3121aee.tar.gz
Lock access to proc members.
Glanced over by: marcel
Diffstat (limited to 'sys/compat/linux/linux_file.c')
-rw-r--r--sys/compat/linux/linux_file.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index d0e531b..1bbe4cc 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -124,14 +124,17 @@ linux_open(struct proc *p, struct linux_open_args *args)
bsd_open_args.mode = args->mode;
error = open(p, &bsd_open_args);
+ PROC_LOCK(p);
if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
struct filedesc *fdp = p->p_fd;
struct file *fp = fdp->fd_ofiles[p->p_retval[0]];
+ PROC_UNLOCK(p);
if (fp->f_type == DTYPE_VNODE)
fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
- }
+ } else
+ PROC_UNLOCK(p);
#ifdef DEBUG
printf("Linux-emul(%d): open returns error %d\n",
p->p_pid, error);
@@ -402,6 +405,7 @@ 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",
@@ -419,7 +423,13 @@ linux_getdents(struct proc *p, struct linux_getdents_args *args)
if (vp->v_type != VDIR)
return (EINVAL);
- if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) {
+ PROC_LOCK(p);
+ uc = p->p_ucred;
+ crhold(uc);
+ PROC_UNLOCK(p);
+ error = VOP_GETATTR(vp, &va, uc, p);
+ crfree(uc);
+ if (error) {
return error;
}
OpenPOWER on IntegriCloud