From owner-freebsd-bugs Tue Jan 16 12:20:28 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 8388337B404 for ; Tue, 16 Jan 2001 12:20:04 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f0GKK4P11509; Tue, 16 Jan 2001 12:20:04 -0800 (PST) (envelope-from gnats) Received: from pancake.netability.ie (unknown [159.134.183.12]) by hub.freebsd.org (Postfix) with ESMTP id 9041537B401 for ; Tue, 16 Jan 2001 12:13:52 -0800 (PST) Received: (from nick@localhost) by pancake.netability.ie (8.11.1/8.11.0) id f0GKDqG04219; Tue, 16 Jan 2001 20:13:52 GMT (envelope-from nick) Message-Id: <200101162013.f0GKDqG04219@pancake.netability.ie> Date: Tue, 16 Jan 2001 20:13:52 GMT From: nick@netability.ie Reply-To: nick@netability.ie To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: kern/24392: bogons in kernel linker Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 24392 >Category: kern >Synopsis: panic() if kldload used to load module which is already compiled into kernel >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jan 16 12:20:02 PST 2001 >Closed-Date: >Last-Modified: >Originator: Nick Hilliard >Release: FreeBSD 4.2-STABLE i386 >Organization: Network Ability Ltd. >Environment: ipfw statically compiled into kernel >Description: FreeBSD will reliably panic if ipfw is compiled into the kernel, and if an attempt is then made to load it dynamically and then unload it using kldload/kldunload. Looking at the code, I'd say that there was nothing particularly special about ipfw, and that it was a more generic problem which affects all kernel modules which register sysctls. What appears to be happening is this: "kldload ipfw" attempts to register ipfw module. This first registers all of the sysctls (kern/kern_linker.c:284 in linker_load_file()), and the on the next line attempts to initialise the module using linker_file_sysinit(). This function calls module_register() which then returns an error (EEXIST), but this error is ignored, and the registration of the module completes further on down the function (oopsie - this is bad!) "kldload ipfw" then unloads the kernel module and de-registers the sysctls which are in use by the statically compiled ipfw module, and panic occurs (didn't get any time to look into what's going on here). >How-To-Repeat: Create kernel with ipfw compiled in statically, then: # kldload ipfw # kldunload ipfw >Fix: Ran out of time for a fix. Looks relatively easy to put in a quick fix, but I'm not familiar enough with the code to feel confident about fixing it - it's very likely that some sublety has escaped me. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message