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 pull up revs 1.111-1.112 from trunk (requested...



details:   https://anonhg.NetBSD.org/src/rev/4fb8059025ae
branches:  netbsd-1-4
changeset: 469556:4fb8059025ae
user:      cgd <cgd%NetBSD.org@localhost>
date:      Sun Oct 10 20:51:15 1999 +0000

description:
pull up revs 1.111-1.112 from trunk (requested by mycroft):
  Fix potential overflow of v_usecount and v_writecount (and panics
  resulting from this) by widening them to `long'.  Mostly affects
  systems where maxvnodes>=32768.

diffstat:

 sys/kern/vfs_subr.c |  27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diffs (71 lines):

diff -r 357b9a065fa0 -r 4fb8059025ae sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Sun Oct 10 20:50:52 1999 +0000
+++ b/sys/kern/vfs_subr.c       Sun Oct 10 20:51:15 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.100 1999/03/24 05:51:26 mrg Exp $       */
+/*     $NetBSD: vfs_subr.c,v 1.100.2.1 1999/10/10 20:51:15 cgd Exp $   */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -862,6 +862,12 @@
                simple_unlock(&vnode_free_list_slock);
        }
        vp->v_usecount++;
+#ifdef DIAGNOSTIC
+       if (vp->v_usecount == 0) {
+               vprint("vget", vp);
+               panic("vget: usecount overflow");
+       }
+#endif
        if (flags & LK_TYPE_MASK) {
                if ((error = vn_lock(vp, flags | LK_INTERLOCK)))
                        vrele(vp);
@@ -880,7 +886,7 @@
 {
        struct proc *p = curproc;       /* XXX */
 
-#ifdef DIGANOSTIC
+#ifdef DIAGNOSTIC
        if (vp == NULL)
                panic("vput: null vp");
 #endif
@@ -984,6 +990,12 @@
        if (vp->v_usecount <= 0)
                panic("vref used where vget required");
        vp->v_usecount++;
+#ifdef DIAGNOSTIC
+       if (vp->v_usecount == 0) {
+               vprint("vref", vp);
+               panic("vref: usecount overflow");
+       }
+#endif
        simple_unlock(&vp->v_interlock);
 }
 #endif /* DIAGNOSTIC */
@@ -1096,9 +1108,16 @@
         * so that its count cannot fall to zero and generate a
         * race against ourselves to recycle it.
         */
-       if ((active = vp->v_usecount) != 0)
+       if ((active = vp->v_usecount) != 0) {
                /* We have the vnode interlock. */
                vp->v_usecount++;
+#ifdef DIAGNOSTIC
+               if (vp->v_usecount == 0) {
+                       vprint("vclean", vp);
+                       panic("vclean: usecount overflow");
+               }
+#endif
+       }
 
        /*
         * Prevent the vnode from being recycled or
@@ -1408,7 +1427,7 @@
 
        if (label != NULL)
                printf("%s: ", label);
-       printf("type %s, usecount %d, writecount %d, refcount %ld,",
+       printf("type %s, usecount %ld, writecount %ld, refcount %ld,",
            typename[vp->v_type], vp->v_usecount, vp->v_writecount,
            vp->v_holdcnt);
        buf[0] = '\0';



Home | Main Index | Thread Index | Old Index