Source-Changes-HG archive

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

[src/trunk]: src/sys/kern fix validation of new values when setting vm.{hi, lo...



details:   https://anonhg.NetBSD.org/src/rev/036278e9b349
branches:  trunk
changeset: 579899:036278e9b349
user:      chs <chs%NetBSD.org@localhost>
date:      Thu Mar 31 02:34:10 2005 +0000

description:
fix validation of new values when setting vm.{hi,low}water.  fixes PR 29651.

diffstat:

 sys/kern/vfs_bio.c |  16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diffs (56 lines):

diff -r 9a8dd6da863d -r 036278e9b349 sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c        Thu Mar 31 00:05:02 2005 +0000
+++ b/sys/kern/vfs_bio.c        Thu Mar 31 02:34:10 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_bio.c,v 1.142 2005/02/26 21:34:56 perry Exp $      */
+/*     $NetBSD: vfs_bio.c,v 1.143 2005/03/31 02:34:10 chs Exp $        */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -81,7 +81,7 @@
 #include "opt_softdep.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.142 2005/02/26 21:34:56 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.143 2005/03/31 02:34:10 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1609,22 +1609,24 @@
 
        node = *rnode;
        node.sysctl_data = &t;
-       t = *(int*)rnode->sysctl_data;
+       t = *(int *)rnode->sysctl_data;
        error = sysctl_lookup(SYSCTLFN_CALL(&node));
        if (error || newp == NULL)
                return (error);
 
+       if (t < 0)
+               return EINVAL;
        if (rnode->sysctl_data == &bufcache) {
-               if (t < 0 || t > 100)
+               if (t > 100)
                        return (EINVAL);
                bufcache = t;
                buf_setwm();
        } else if (rnode->sysctl_data == &bufmem_lowater) {
-               if (bufmem_hiwater - bufmem_lowater < 16)
+               if (bufmem_hiwater - t < 16)
                        return (EINVAL);
                bufmem_lowater = t;
        } else if (rnode->sysctl_data == &bufmem_hiwater) {
-               if (bufmem_hiwater - bufmem_lowater < 16)
+               if (t - bufmem_lowater < 16)
                        return (EINVAL);
                bufmem_hiwater = t;
        } else
@@ -1632,7 +1634,7 @@
 
        /* Drain until below new high water mark */
        while ((t = bufmem - bufmem_hiwater) >= 0) {
-               if (buf_drain(t / (2*1024)) <= 0)
+               if (buf_drain(t / (2 * 1024)) <= 0)
                        break;
        }
 



Home | Main Index | Thread Index | Old Index