From owner-freebsd-amd64@FreeBSD.ORG Mon May 31 10:46:08 2004 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C378916A4CE for ; Mon, 31 May 2004 10:46:08 -0700 (PDT) Received: from transport.cksoft.de (transport.cksoft.de [62.111.66.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1613743D39 for ; Mon, 31 May 2004 10:46:08 -0700 (PDT) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from transport.cksoft.de (localhost [127.0.0.1]) by transport.cksoft.de (Postfix) with ESMTP id 145D51FFDD3 for ; Mon, 31 May 2004 19:45:40 +0200 (CEST) Received: by transport.cksoft.de (Postfix, from userid 66) id 1FCBF1FF931; Mon, 31 May 2004 19:45:38 +0200 (CEST) Received: by mail.int.zabbadoz.net (Postfix, from userid 1060) id 60DBA154E2; Mon, 31 May 2004 17:44:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.int.zabbadoz.net (Postfix) with ESMTP id 560911539E for ; Mon, 31 May 2004 17:45:00 +0000 (UTC) Date: Mon, 31 May 2004 17:45:00 +0000 (UTC) From: "Bjoern A. Zeeb" X-X-Sender: bz@e0-0.zab2.int.zabbadoz.net To: FreeBSD amd64 mailing list Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS cksoft-s20020300-20031204bz on transport.cksoft.de Subject: crash: sysctls in dependend modules crash machine X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 May 2004 17:46:08 -0000 Hi, let's say module a defines a new sysctl node (SYSCTL_DECL in shared header file): --- cut a.c --- SYSCTL_NODE (, OID_AUTO, testsysctl, CTLFLAG_RW, 0, "Test kld dependend sysctls"); SYSCTL_NODE(_testsysctl, OID_AUTO, modulea, CTLFLAG_RW, 0, "module a"); int a = 1; SYSCTL_INT(_testsysctl_modulea, OID_AUTO, a, CTLFLAG_RW, &a, 0, "a"); --- / a.c --- and module b depends on module a and adds following: --- cut b.c --- SYSCTL_NODE(_testsysctl, OID_AUTO, moduleb, CTLFLAG_RW, 0, "module b"); int b = 1; SYSCTL_INT(_testsysctl_moduleb, OID_AUTO, b, CTLFLAG_RW, &b, 0, "b"); --- / b.c --- loading module a will work: noc# kldload -v ./test_sysctl_base.ko test_sysctl_base KLD loaded. Loaded ./test_sysctl_base.ko, id=4 noc# kldstat Id Refs Address Size Name 1 2 0xffffffff80100000 830ad8 kernel 4 1 0xffffffff98d76000 2c7 test_sysctl_base.ko BUT: loading module b will crash the machine: noc# cd ../b/ noc# kldload -v ./test_sysctl_b.ko (handwritten bt): sysctl_find_oidname+0x14 sysctl_register_oid+0x19 linker_file_register_sysctls+0x3c linker_load_file+0xe7 linker_load_module+0xd8 kldload+0xf3 sysctl+0x358 ... To reproduce you can find two quickly hacked up sample modules at http://sources.zabbadoz.net/freebsd/amd64/amd64-modules-sysctl.tbz tar xjvf amd64-modules-sysctl.tbz cd amd64-modules-sysctl/a make su kldload -v ./test_sysctl_base.ko exit kldstat cd ../b make su echo "be sure to mount your partitions ro now; I will crash" mount -u -o ro ... /usr / kldload -v ./test_sysctl_b.ko -- Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT