summaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2002-02-12 18:41:22 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2002-02-12 18:41:22 +0000
commitbce72aba44fc06f9485a2c002aebaa7fd92f58c9 (patch)
treea901de254a1adbbb79ca2af589bd871ea67cf9d7 /sys/compat
parent10bd0832e038949eb0133f149a0bbe6f9501c17a (diff)
More FREF/FRELE protection. This time all users of getvnode.
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/common/vfs_syscalls_25.c11
-rw-r--r--sys/compat/common/vfs_syscalls_43.c15
-rw-r--r--sys/compat/freebsd/freebsd_file.c7
-rw-r--r--sys/compat/ibcs2/ibcs2_misc.c25
-rw-r--r--sys/compat/ibcs2/ibcs2_stat.c7
-rw-r--r--sys/compat/linux/linux_misc.c4
-rw-r--r--sys/compat/netbsd/netbsd_file.c7
-rw-r--r--sys/compat/netbsd/netbsd_getdents.c4
-rw-r--r--sys/compat/osf1/osf1_mount.c8
-rw-r--r--sys/compat/sunos/sunos_misc.c24
-rw-r--r--sys/compat/svr4/svr4_misc.c24
-rw-r--r--sys/compat/ultrix/ultrix_pathname.c7
12 files changed, 96 insertions, 47 deletions
diff --git a/sys/compat/common/vfs_syscalls_25.c b/sys/compat/common/vfs_syscalls_25.c
index 03d01687d45..b073e1eaada 100644
--- a/sys/compat/common/vfs_syscalls_25.c
+++ b/sys/compat/common/vfs_syscalls_25.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls_25.c,v 1.1 2001/05/16 17:14:38 millert Exp $ */
+/* $OpenBSD: vfs_syscalls_25.c,v 1.2 2002/02/12 18:41:20 art Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -135,21 +135,24 @@ compat_25_sys_fstatfs(p, v, retval)
void *v;
register_t *retval;
{
- register struct compat_25_sys_fstatfs_args /* {
+ struct compat_25_sys_fstatfs_args /* {
syscallarg(int) fd;
syscallarg(struct ostatfs *) buf;
} */ *uap = v;
struct file *fp;
struct mount *mp;
- register struct statfs *sp;
+ struct statfs *sp;
struct ostatfs osb;
int error;
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
statfs_to_ostatfs(p, mp, sp, &osb);
diff --git a/sys/compat/common/vfs_syscalls_43.c b/sys/compat/common/vfs_syscalls_43.c
index 976043be90c..e9ccc4c1e83 100644
--- a/sys/compat/common/vfs_syscalls_43.c
+++ b/sys/compat/common/vfs_syscalls_43.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls_43.c,v 1.16 2001/11/06 19:53:17 miod Exp $ */
+/* $OpenBSD: vfs_syscalls_43.c,v 1.17 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: vfs_syscalls_43.c,v 1.4 1996/03/14 19:31:52 christos Exp $ */
/*
@@ -355,10 +355,13 @@ compat_43_sys_getdirentries(p, v, retval)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
+ FREF(fp);
vp = (struct vnode *)fp->f_data;
unionread:
- if (vp->v_type != VDIR)
- return (EINVAL);
+ if (vp->v_type != VDIR) {
+ error = EINVAL;
+ goto bad;
+ }
aiov.iov_base = SCARG(uap, buf);
aiov.iov_len = SCARG(uap, count);
auio.uio_iov = &aiov;
@@ -428,13 +431,13 @@ unionread:
}
VOP_UNLOCK(vp, 0, p);
if (error)
- return (error);
+ goto bad;
if ((SCARG(uap, count) == auio.uio_resid) &&
union_check_p &&
(union_check_p(p, &vp, fp, auio, &error) != 0))
goto unionread;
if (error)
- return (error);
+ goto bad;
if ((SCARG(uap, count) == auio.uio_resid) &&
(vp->v_flag & VROOT) &&
@@ -450,5 +453,7 @@ unionread:
error = copyout((caddr_t)&loff, (caddr_t)SCARG(uap, basep),
sizeof(long));
*retval = SCARG(uap, count) - auio.uio_resid;
+bad:
+ FRELE(fp);
return (error);
}
diff --git a/sys/compat/freebsd/freebsd_file.c b/sys/compat/freebsd/freebsd_file.c
index 4ef1e246661..483dc4d94ba 100644
--- a/sys/compat/freebsd/freebsd_file.c
+++ b/sys/compat/freebsd/freebsd_file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: freebsd_file.c,v 1.11 2001/10/26 12:03:27 art Exp $ */
+/* $OpenBSD: freebsd_file.c,v 1.12 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: freebsd_file.c,v 1.3 1996/05/03 17:03:09 christos Exp $ */
/*
@@ -623,7 +623,10 @@ freebsd_sys_fstatfs(p, v, retval)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
diff --git a/sys/compat/ibcs2/ibcs2_misc.c b/sys/compat/ibcs2/ibcs2_misc.c
index 8688ded925e..e22a525f44c 100644
--- a/sys/compat/ibcs2/ibcs2_misc.c
+++ b/sys/compat/ibcs2/ibcs2_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ibcs2_misc.c,v 1.19 2001/11/06 19:53:17 miod Exp $ */
+/* $OpenBSD: ibcs2_misc.c,v 1.20 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: ibcs2_misc.c,v 1.23 1997/01/15 01:37:49 perry Exp $ */
/*
@@ -434,15 +434,16 @@ ibcs2_sys_getdents(p, v, retval)
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
args.resid = SCARG(uap, nbytes);
args.outp = (caddr_t)SCARG(uap, buf);
-
- if ((error = readdir_with_callback(fp, &fp->f_offset, args.resid,
- ibcs2_readdir_callback, &args)) != 0)
+ error = readdir_with_callback(fp, &fp->f_offset, args.resid,
+ ibcs2_readdir_callback, &args)
+ FRELE(fp);
+ if (error)
return (error);
*retval = SCARG(uap, nbytes) - args.resid;
-
return (0);
}
@@ -474,15 +475,17 @@ ibcs2_sys_read(p, v, retval)
if (vp->v_type != VDIR)
return sys_read(p, uap, retval);
+ FREF(fp);
args.resid = SCARG(uap, nbytes);
args.outp = (caddr_t)SCARG(uap, buf);
-
- if ((error = readdir_with_callback(fp, &fp->f_offset, args.resid,
- ibcs2_classicread_callback, &args)) != 0)
+
+ error = readdir_with_callback(fp, &fp->f_offset, args.resid,
+ ibcs2_classicread_callback, &args);
+ FRELE(fp);
+ if (error)
return (error);
-
- *retval = SCARG(uap, nbytes) - args.resid;
-
+
+ *retval = SCARG(uap, nbytes) - args.resid;
return (0);
}
diff --git a/sys/compat/ibcs2/ibcs2_stat.c b/sys/compat/ibcs2/ibcs2_stat.c
index 97bba65505b..53c6b6b7c1a 100644
--- a/sys/compat/ibcs2/ibcs2_stat.c
+++ b/sys/compat/ibcs2/ibcs2_stat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ibcs2_stat.c,v 1.6 2001/11/06 19:53:17 miod Exp $ */
+/* $OpenBSD: ibcs2_stat.c,v 1.7 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: ibcs2_stat.c,v 1.5 1996/05/03 17:05:32 christos Exp $ */
/*
@@ -149,7 +149,10 @@ ibcs2_sys_fstatfs(p, v, retval)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len));
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 091b1d7b089..15072100460 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_misc.c,v 1.39 2001/11/06 19:53:17 miod Exp $ */
+/* $OpenBSD: linux_misc.c,v 1.40 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */
/*
@@ -1022,6 +1022,7 @@ linux_sys_getdents(p, v, retval)
args.resid = nbytes;
args.outp = (caddr_t)SCARG(uap, dirent);
+ FREF(fp);
if ((error = readdir_with_callback(fp, &fp->f_offset, nbytes,
linux_readdir_callback, &args)) != 0)
goto exit;
@@ -1029,6 +1030,7 @@ linux_sys_getdents(p, v, retval)
*retval = nbytes - args.resid;
exit:
+ FRELE(fp);
return (error);
}
diff --git a/sys/compat/netbsd/netbsd_file.c b/sys/compat/netbsd/netbsd_file.c
index 5fe0988a34c..61d19bd5c6a 100644
--- a/sys/compat/netbsd/netbsd_file.c
+++ b/sys/compat/netbsd/netbsd_file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netbsd_file.c,v 1.1 1999/09/17 22:14:09 kstailey Exp $ */
+/* $OpenBSD: netbsd_file.c,v 1.2 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: freebsd_file.c,v 1.3 1996/05/03 17:03:09 christos Exp $ */
/*
@@ -597,7 +597,10 @@ netbsd_sys_fstatfs(p, v, retval)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
diff --git a/sys/compat/netbsd/netbsd_getdents.c b/sys/compat/netbsd/netbsd_getdents.c
index aad9e1a2d45..7e92951d5e4 100644
--- a/sys/compat/netbsd/netbsd_getdents.c
+++ b/sys/compat/netbsd/netbsd_getdents.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netbsd_getdents.c,v 1.4 2001/09/05 23:38:28 art Exp $ */
+/* $OpenBSD: netbsd_getdents.c,v 1.5 2002/02/12 18:41:20 art Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -167,9 +167,11 @@ netbsd_sys_getdents(p, v, retval)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
+ FREF(fp);
error = netbsd_vn_readdir(fp, SCARG(uap, buf), UIO_USERSPACE,
SCARG(uap, count), &done, p, 0, 0);
*retval = done;
+ FRELE(fp);
return (error);
}
diff --git a/sys/compat/osf1/osf1_mount.c b/sys/compat/osf1/osf1_mount.c
index 2872db884eb..506d18bca6b 100644
--- a/sys/compat/osf1/osf1_mount.c
+++ b/sys/compat/osf1/osf1_mount.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: osf1_mount.c,v 1.5 2000/08/04 15:47:55 ericj Exp $ */
+/* $OpenBSD: osf1_mount.c,v 1.6 2002/02/12 18:41:20 art Exp $ */
/* $NetBSD: osf1_mount.c,v 1.14 1999/05/05 01:51:34 cgd Exp $ */
/*
@@ -117,12 +117,14 @@ osf1_sys_fstatfs(p, v, retval)
struct osf1_statfs osfs;
int error;
- /* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)))
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)))
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
goto out;
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
osf1_cvt_statfs_from_native(sp, &osfs);
diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c
index d3a4371c7f4..939288415d7 100644
--- a/sys/compat/sunos/sunos_misc.c
+++ b/sys/compat/sunos/sunos_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunos_misc.c,v 1.32 2002/02/12 13:05:31 art Exp $ */
+/* $OpenBSD: sunos_misc.c,v 1.33 2002/02/12 18:41:21 art Exp $ */
/* $NetBSD: sunos_misc.c,v 1.65 1996/04/22 01:44:31 christos Exp $ */
/*
@@ -441,9 +441,12 @@ sunos_sys_getdents(p, v, retval)
args.resid = SCARG(uap, nbytes);
args.outp = (caddr_t)SCARG(uap, buf);
-
- if ((error = readdir_with_callback(fp, &fp->f_offset, args.resid,
- sunos_readdir_callback, &args)) != 0)
+
+ FREF(fp);
+ error = readdir_with_callback(fp, &fp->f_offset, args.resid,
+ sunos_readdir_callback, &args);
+ FRELE(fp);
+ if (error)
return (error);
*retval = SCARG(uap, nbytes) - args.resid;
@@ -594,18 +597,22 @@ sunos_sys_fchroot(p, v, retval)
if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
return (error);
vp = (struct vnode *)fp->f_data;
+ FREF(fp);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
if (vp->v_type != VDIR)
error = ENOTDIR;
else
error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
VOP_UNLOCK(vp, 0, p);
- if (error)
+ if (error) {
+ FRELE(fp);
return (error);
+ }
VREF(vp);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
fdp->fd_rdir = vp;
+ FRELE(fp);
return (0);
}
@@ -849,14 +856,17 @@ sunos_sys_fstatfs(p, v, retval)
struct sunos_sys_fstatfs_args *uap = v;
struct file *fp;
struct mount *mp;
- register struct statfs *sp;
+ struct statfs *sp;
int error;
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ FREF(fp);
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return sunstatfs(sp, (caddr_t)SCARG(uap, buf));
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index 99d911bdcf1..4eebd06f5af 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_misc.c,v 1.38 2001/11/28 13:47:39 art Exp $ */
+/* $OpenBSD: svr4_misc.c,v 1.39 2002/02/12 18:41:21 art Exp $ */
/* $NetBSD: svr4_misc.c,v 1.42 1996/12/06 03:22:34 christos Exp $ */
/*
@@ -304,9 +304,12 @@ svr4_sys_getdents(p, v, retval)
args.resid = SCARG(uap, nbytes);
args.outp = (caddr_t)SCARG(uap, buf);
-
- if ((error = readdir_with_callback(fp, &fp->f_offset, SCARG(uap, nbytes),
- svr4_readdir_callback, &args)) != 0)
+
+ FREF(fp);
+ error = readdir_with_callback(fp, &fp->f_offset, SCARG(uap, nbytes),
+ svr4_readdir_callback, &args);
+ FRELE(fp);
+ if (error)
return (error);
*retval = SCARG(uap, nbytes) - args.resid;
@@ -330,9 +333,12 @@ svr4_sys_getdents64(p, v, retval)
args.resid = SCARG(uap, nbytes);
args.outp = (caddr_t)SCARG(uap, dp);
-
- if ((error = readdir_with_callback(fp, &fp->f_offset, SCARG(uap, nbytes),
+
+ FREF(fp);
+ error = readdir_with_callback(fp, &fp->f_offset, SCARG(uap, nbytes),
svr4_readdir64_callback, &args)) != 0)
+ FRELE(fp);
+ if (error)
return (error);
*retval = SCARG(uap, nbytes) - args.resid;
@@ -424,6 +430,7 @@ svr4_sys_fchroot(p, v, retval)
return error;
if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
return error;
+ FREF(fp);
vp = (struct vnode *) fp->f_data;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
if (vp->v_type != VDIR)
@@ -431,12 +438,15 @@ svr4_sys_fchroot(p, v, retval)
else
error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
VOP_UNLOCK(vp, 0, p);
- if (error)
+ if (error) {
+ FRELE(fp);
return error;
+ }
VREF(vp);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
fdp->fd_rdir = vp;
+ FRELE(fp);
return 0;
}
diff --git a/sys/compat/ultrix/ultrix_pathname.c b/sys/compat/ultrix/ultrix_pathname.c
index b4e55576064..1073053c24c 100644
--- a/sys/compat/ultrix/ultrix_pathname.c
+++ b/sys/compat/ultrix/ultrix_pathname.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ultrix_pathname.c,v 1.5 2002/02/02 16:05:58 art Exp $ */
+/* $OpenBSD: ultrix_pathname.c,v 1.6 2002/02/12 18:41:21 art Exp $ */
/* $NetBSD: ultrix_pathname.c,v 1.2 1996/04/07 17:23:07 jonathan Exp $ */
/*
@@ -282,9 +282,12 @@ ultrix_sys_fstatfs(p, v, retval)
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
+ FREF(fp);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
+ error = VFS_STATFS(mp, sp, p);
+ FRELE(fp);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return ultrixstatfs(sp, (caddr_t)SCARG(uap, buf));