diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-08-16 02:00:51 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-08-16 02:00:51 +0000 |
commit | bce570d08083523723a1c79a5ec46cbbd09ea90e (patch) | |
tree | 180663de9f60f8e6bb3d499cac2b9bcacb41c918 /sys/miscfs/procfs/procfs_vnops.c | |
parent | 637e2dae259da04f9fc095b5dee434da3e99d93b (diff) |
1) pfs_mode should be mode_t, not u_short
2) Fix procfs security hole. This is basically the NetBSD fix
(which is based in part on Sean Eric Fagan's FreeBSD fix)
with a few minor changes. The change creates as function,
procfs_checkioperm(), that has check numbers 3 and 4 from sys_ptrace().
3) Make procfs_control() use procfs_checkioperm() as well (it
already had the same basic checks but some of them were incorrect).
4) Minor stylistic cleanups, including the use of the SET/CLR/ISSET
macros to aid general grokability.
Diffstat (limited to 'sys/miscfs/procfs/procfs_vnops.c')
-rw-r--r-- | sys/miscfs/procfs/procfs_vnops.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c index 2d9d840aebe..d125626df43 100644 --- a/sys/miscfs/procfs/procfs_vnops.c +++ b/sys/miscfs/procfs/procfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procfs_vnops.c,v 1.4 1997/08/01 05:58:57 millert Exp $ */ +/* $OpenBSD: procfs_vnops.c,v 1.5 1997/08/16 02:00:50 millert Exp $ */ /* $NetBSD: procfs_vnops.c,v 1.40 1996/03/16 23:52:55 christos Exp $ */ /* @@ -217,16 +217,22 @@ procfs_open(v) struct proc *a_p; } */ *ap = v; struct pfsnode *pfs = VTOPFS(ap->a_vp); + struct proc *p1 = ap->a_p; + struct proc *p2; + int error; + + if ((p2 = PFIND(pfs->pfs_pid)) == 0) + return (ENOENT); /* was ESRCH, jsp */ switch (pfs->pfs_type) { case Pmem: - if (PFIND(pfs->pfs_pid) == 0) - return (ENOENT); /* was ESRCH, jsp */ - if (((pfs->pfs_flags & FWRITE) && (ap->a_mode & O_EXCL)) || ((pfs->pfs_flags & O_EXCL) && (ap->a_mode & FWRITE))) return (EBUSY); + if ((error = procfs_checkioperm(p1, p2)) != 0) + return (error); + if (ap->a_mode & FWRITE) pfs->pfs_flags = ap->a_mode & (FWRITE|O_EXCL); @@ -427,15 +433,15 @@ procfs_print(v) } int -procfs_link(v) +procfs_link(v) void *v; { struct vop_link_args /* { struct vnode *a_dvp; - struct vnode *a_vp; + struct vnode *a_vp; struct componentname *a_cnp; } */ *ap = v; - + VOP_ABORTOP(ap->a_dvp, ap->a_cnp); vput(ap->a_dvp); return (EROFS); @@ -452,7 +458,7 @@ procfs_symlink(v) struct vattr *a_vap; char *a_target; } */ *ap = v; - + VOP_ABORTOP(ap->a_dvp, ap->a_cnp); vput(ap->a_dvp); return (EROFS); |