Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-2-0]: src/sys/miscfs/procfs Pull up following revision(s) (reques...



details:   https://anonhg.NetBSD.org/src/rev/d9f8cb474219
branches:  netbsd-2-0
changeset: 564841:d9f8cb474219
user:      tron <tron%NetBSD.org@localhost>
date:      Wed Aug 31 13:41:38 2005 +0000

description:
Pull up following revision(s) (requested by christos in ticket #5634):
        sys/miscfs/procfs/procfs_subr.c: revision 1.59
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:

 sys/miscfs/procfs/procfs_subr.c |  34 +++++++++++-----------------------
 1 files changed, 11 insertions(+), 23 deletions(-)

diffs (64 lines):

diff -r eae98a18f5d3 -r d9f8cb474219 sys/miscfs/procfs/procfs_subr.c
--- a/sys/miscfs/procfs/procfs_subr.c   Wed Aug 31 13:29:40 2005 +0000
+++ b/sys/miscfs/procfs/procfs_subr.c   Wed Aug 31 13:41:38 2005 +0000
@@ -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.58.2.1 2005/08/31 13:41:38 tron 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.58.2.1 2005/08/31 13:41:38 tron Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -299,9 +299,17 @@
        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 @@
        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));



Home | Main Index | Thread Index | Old Index