Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Add a check to ensure that a new sysctl node was at...



details:   https://anonhg.NetBSD.org/src/rev/37462362b665
branches:  trunk
changeset: 823494:37462362b665
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Tue Apr 25 22:07:10 2017 +0000

description:
Add a check to ensure that a new sysctl node was attached in the tree
at the place we expected it to be attached!

As mentioned several times (on tech-kern@ mailing list) over the past
18 months or so, I've seen a few instances where this will trigger,
although I've been unable to reproduce them.  Hopefully some wider
exposure will reveal the under-lying cause of this rare phenomenon.

Commit was proposed on tech-kern list, and no objections raised.

diffstat:

 sys/kern/kern_sysctl.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (43 lines):

diff -r 0d614da26ef6 -r 37462362b665 sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c    Tue Apr 25 18:52:31 2017 +0000
+++ b/sys/kern/kern_sysctl.c    Tue Apr 25 22:07:10 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sysctl.c,v 1.258 2015/10/23 01:58:43 pgoyette Exp $       */
+/*     $NetBSD: kern_sysctl.c,v 1.259 2017/04/25 22:07:10 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.258 2015/10/23 01:58:43 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.259 2017/04/25 22:07:10 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_defcorename.h"
@@ -1955,6 +1955,7 @@
        const struct sysctlnode *root, *pnode;
        struct sysctlnode nnode, onode, *dnode;
        size_t sz;
+       const struct sysctlnode *snode __diagused;
 
        /*
         * where are we putting this?
@@ -2111,6 +2112,7 @@
                 */
                pnode = root;
                error = sysctl_locate(NULL, &name[0], namelen - 1, &pnode, &ni);
+               snode = pnode;
 
                /*
                 * manual scan of last layer so that aliased nodes
@@ -2131,6 +2133,8 @@
                 * not expecting an error here, but...
                 */
                if (error == 0) {
+                       KASSERTMSG(pnode->sysctl_parent == snode,
+                           "sysctl parent mis-match");
                        if (log != NULL)
                                sysctl_log_add(log, pnode);
                        if (cnode != NULL)



Home | Main Index | Thread Index | Old Index