summaryrefslogtreecommitdiff
path: root/sys/miscfs/procfs
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2004-05-14 16:35:24 +0000
committerchristos <christos@NetBSD.org>2004-05-14 16:35:24 +0000
commit999e9cef64de4d4088717f5afabdf9538f55660f (patch)
tree22f66a0d6506f175b01c498a2400b0124c082c1d /sys/miscfs/procfs
parentc489489b142954ca97a43173f4b84f691e356548 (diff)
Simplify the code by:
1. Checking for a negative uio_offset at the beginning. This really does not affect us in most cases because we check that later too. 2. Checking for attempts to write to init sooner and in all cases.
Diffstat (limited to 'sys/miscfs/procfs')
-rw-r--r--sys/miscfs/procfs/procfs_subr.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c
index 9a874d5b9e8..49dd6c1a817 100644
--- a/sys/miscfs/procfs/procfs_subr.c
+++ b/sys/miscfs/procfs/procfs_subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: procfs_subr.c,v 1.58 2003/09/27 13:29:02 darcy Exp $ */
+/* $NetBSD: procfs_subr.c,v 1.59 2004/05/14 16:35:24 christos Exp $ */
/*
* Copyright (c) 1993
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.58 2003/09/27 13:29:02 darcy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.59 2004/05/14 16:35:24 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -299,9 +299,17 @@ procfs_rw(v)
struct lwp *l;
struct proc *p;
+ if (uio->uio_offset < 0)
+ return EINVAL;
p = PFIND(pfs->pfs_pid);
if (p == 0)
- return (EINVAL);
+ return ESRCH;
+ /*
+ * Do not allow init to be modified while in secure mode; it
+ * could be duped into changing the security level.
+ */
+ if (uio->uio_rw == UIO_WRITE && p == initproc && securelevel > -1)
+ return EPERM;
/* XXX NJWLWP
* The entire procfs interface needs work to be useful to
@@ -311,26 +319,6 @@ procfs_rw(v)
l = proc_representative_lwp(p);
switch (pfs->pfs_type) {
- case PFSregs:
- case PFSfpregs:
- case PFSmem:
-#if defined(__HAVE_PROCFS_MACHDEP) && defined(PROCFS_MACHDEP_PROTECT_CASES)
- PROCFS_MACHDEP_PROTECT_CASES
-#endif
- /*
- * Do not allow init to be modified while in secure mode; it
- * could be duped into changing the security level.
- */
- if (uio->uio_rw == UIO_WRITE &&
- p == initproc && securelevel > -1)
- return (EPERM);
- break;
-
- default:
- break;
- }
-
- switch (pfs->pfs_type) {
case PFSnote:
case PFSnotepg:
return (procfs_donote(curp, p, pfs, uio));