Source-Changes-HG archive

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

[src/netbsd-1-4]: src/sys/kern Modify/re-do last pullup (via patch, requested...



details:   https://anonhg.NetBSD.org/src/rev/7ed5d1cc7787
branches:  netbsd-1-4
changeset: 470543:7ed5d1cc7787
user:      he <he%NetBSD.org@localhost>
date:      Sun Apr 30 20:12:42 2000 +0000

description:
Modify/re-do last pullup (via patch, requested by sommerfeld):
  Fix two bugs:
   o A malicious or erroneous program can hog the CPU in uiomove()
   o A ktrace of such a program can hog large amounts of kernel memory
  This version of the fix does not increase the size of struct proc
  compared to 1.4.2.

diffstat:

 sys/kern/kern_ktrace.c |   4 ++--
 sys/kern/kern_subr.c   |   4 ++--
 sys/kern/kern_synch.c  |  11 ++++++-----
 3 files changed, 10 insertions(+), 9 deletions(-)

diffs (81 lines):

diff -r 7ba7717be06d -r 7ed5d1cc7787 sys/kern/kern_ktrace.c
--- a/sys/kern/kern_ktrace.c    Sun Apr 30 20:12:04 2000 +0000
+++ b/sys/kern/kern_ktrace.c    Sun Apr 30 20:12:42 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_ktrace.c,v 1.33.6.1 2000/04/30 12:08:33 he Exp $  */
+/*     $NetBSD: kern_ktrace.c,v 1.33.6.2 2000/04/30 20:13:33 he Exp $  */
 
 /*
  * Copyright (c) 1989, 1993
@@ -231,7 +231,7 @@
        buflen -= sizeof(struct ktr_genio);
 
        while (resid > 0) {
-               if (p->p_schedflags & PSCHED_SHOULDYIELD)
+               if (schedflags & PSCHED_SHOULDYIELD)
                        preempt(NULL);
 
                cnt = min(iov->iov_len, buflen);
diff -r 7ba7717be06d -r 7ed5d1cc7787 sys/kern/kern_subr.c
--- a/sys/kern/kern_subr.c      Sun Apr 30 20:12:04 2000 +0000
+++ b/sys/kern/kern_subr.c      Sun Apr 30 20:12:42 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_subr.c,v 1.45.2.2 2000/04/30 12:07:35 he Exp $    */
+/*     $NetBSD: kern_subr.c,v 1.45.2.3 2000/04/30 20:12:42 he Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -146,7 +146,7 @@
                switch (uio->uio_segflg) {
 
                case UIO_USERSPACE:
-                       if (p->p_schedflags & PSCHED_SHOULDYIELD)
+                       if (schedflags & PSCHED_SHOULDYIELD)
                                preempt(NULL);
                        if (uio->uio_rw == UIO_READ)
                                error = copyout(cp, iov->iov_base, cnt);
diff -r 7ba7717be06d -r 7ed5d1cc7787 sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c     Sun Apr 30 20:12:04 2000 +0000
+++ b/sys/kern/kern_synch.c     Sun Apr 30 20:12:42 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_synch.c,v 1.57.2.2 2000/04/30 12:08:06 he Exp $   */
+/*     $NetBSD: kern_synch.c,v 1.57.2.3 2000/04/30 20:13:11 he Exp $   */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -105,6 +105,7 @@
 
 u_char curpriority;            /* usrpri of curproc */
 int    lbolt;                  /* once a second sleep address */
+int    schedflags;             /* preemption needed? */
 
 void roundrobin __P((void *));
 void schedcpu __P((void *));
@@ -123,15 +124,15 @@
 
        if (curproc != NULL) {
                s = splstatclock();
-               if (curproc->p_schedflags & PSCHED_SEENRR) {
+               if (schedflags & PSCHED_SEENRR) {
                        /*
                         * The process has already been through a roundrobin
                         * without switching and may be hogging the CPU.
                         * Indicate that the process should yield.
                         */
-                       curproc->p_schedflags |= PSCHED_SHOULDYIELD;
+                       schedflags |= PSCHED_SHOULDYIELD;
                } else
-                       curproc->p_schedflags |= PSCHED_SEENRR;
+                       schedflags |= PSCHED_SEENRR;
                splx(s);
        }
        need_resched();
@@ -726,7 +727,7 @@
         * Process is about to yield the CPU; clear the appropriate
         * scheduling flags.
         */
-       p->p_schedflags &= ~PSCHED_SWITCHCLEAR;
+       schedflags &= ~PSCHED_SWITCHCLEAR;
 
        /*
         * Pick a new current process and record its start time.



Home | Main Index | Thread Index | Old Index