From owner-freebsd-bugs Tue Dec 3 7: 0:12 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 49D6C37B401 for ; Tue, 3 Dec 2002 07:00:09 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D388043EA9 for ; Tue, 3 Dec 2002 07:00:08 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gB3F08x3049416 for ; Tue, 3 Dec 2002 07:00:08 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gB3F08gf049415; Tue, 3 Dec 2002 07:00:08 -0800 (PST) Date: Tue, 3 Dec 2002 07:00:08 -0800 (PST) Message-Id: <200212031500.gB3F08gf049415@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Hiten Pandya Subject: Re: kern/31490: Panic in sysctl_sysctl_next_ls on empy node Reply-To: Hiten Pandya Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR kern/31490; it has been noted by GNATS. From: Hiten Pandya To: bug-followup@FreeBSD.org Cc: Subject: Re: kern/31490: Panic in sysctl_sysctl_next_ls on empy node Date: Tue, 3 Dec 2002 09:56:11 -0500 Hi there. This bug happens in 5.0-CURRENT, and it seems that it is a very old bug. I have some test code, which was devised by me to find this bug, when it was discussed by me, Brian Feldman and Robert Watson; it happened in the MAC_DEBUG code. Test code: http://www.unixdaemons.com/~hiten/work/misc/sysctlbug1.c I have attached the test case, and an updated patch with this followup. TEST CASE: ========== %---- /* * Code for reproducing Sysctl (empty node) bug. */ #include #include #include #include #include static int bug_load(module_t, int, void *); SYSCTL_DECL(_bugfoo); SYSCTL_NODE(, 0, bugfoo, CTLFLAG_RW, 0, "Bugfoo and Family"); SYSCTL_NODE(_bugfoo, OID_AUTO, mac, CTLFLAG_RW, 0, "Bugfoo and Family"); SYSCTL_NODE(_bugfoo_mac, OID_AUTO, debug, CTLFLAG_RW, 0, "BF [1]"); SYSCTL_NODE(_bugfoo_mac_debug, OID_AUTO, counters, CTLFLAG_RW, 0, "BF [2]"); static int mac_debug_label_fallback = 0; SYSCTL_INT(_bugfoo_mac_debug, OID_AUTO, label_fallback, CTLFLAG_RW, &mac_debug_label_fallback, 0, "Filesystems should fall back to fs label" "when label is corrupted."); TUNABLE_INT("bugfoo.mac.debug_label_fallback", &mac_debug_label_fallback); /* Module initialisation stuff */ static moduledata_t bugctl_mod = { "bugctl", bug_load, 0 }; static int bug_load(module_t mod, int cmd, void *arg) { int err = 0; switch (cmd) { case MOD_LOAD: printf("Sysctl Bug Manipulation\n"); break; /* Success*/ case MOD_UNLOAD: break; /* Success */ default: err = EINVAL; break; } return(err); } /* Now declare the module to the system */ DECLARE_MODULE(bugctl, bugctl_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); ----% UPDATED PATCH: ============== Index: kern_sysctl.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_sysctl.c,v retrieving revision 1.135 diff -u -r1.135 kern_sysctl.c --- kern_sysctl.c 2002/10/27 07:12:34 1.135 +++ kern_sysctl.c 2002/12/03 14:51:07 @@ -538,7 +538,10 @@ int *next, int *len, int level, struct sysctl_oid **oidpp) { struct sysctl_oid *oidp; + int i_namelen; + i_namelen = namelen ? 1 : 0; + *len = level; SLIST_FOREACH(oidp, lsp, oid_link) { *next = oidp->oid_number; @@ -585,7 +588,7 @@ len, level+1, oidpp)) return (0); next: - namelen = 1; + namelen = i_namelen; *len = level; } return 1; Cheers. -- Hiten Pandya (hiten@unixdaemons.com, hiten@uk.FreeBSD.org) http://www.unixdaemons.com/~hiten/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message