From owner-freebsd-bugs Thu Mar 18 10:30:23 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 742B314DBF for ; Thu, 18 Mar 1999 10:30:19 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.2/8.9.2) id KAA67070; Thu, 18 Mar 1999 10:30:00 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: by hub.freebsd.org (Postfix, from userid 32767) id 7085D1550A; Thu, 18 Mar 1999 10:21:27 -0800 (PST) Message-Id: <19990318182127.7085D1550A@hub.freebsd.org> Date: Thu, 18 Mar 1999 10:21:27 -0800 (PST) From: M.Indlekofer@fz-juelich.de To: freebsd-gnats-submit@freebsd.org X-Send-Pr-Version: www-1.0 Subject: kern/10653: cdevsw_module_handler MOD_UNLOAD problem Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 10653 >Category: kern >Synopsis: cdevsw_module_handler MOD_UNLOAD problem >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Mar 18 10:30:00 PST 1999 >Closed-Date: >Last-Modified: >Originator: Michael Indlekofer >Release: 3.1-RELEASE >Organization: Forschungs Zentrum Juelich GmbH >Environment: FreeBSD control10... 3.1-RELEASE FreeBSD 3.1-RELEASE #0: Tue Mar 16 13:31:56 GMT 1999 root@control10.../usr/src/sys/compile/MYKERNEL.3 i386 >Description: A char device driver which uses CDEV_MODULE(xxx_mod,MYMAJOR,xxx_devsw,xxx_handler,0) and wants to prevent an unloading of the module (because some devices he offers are still in use e.g.) has a problem: kldunload -> /sys/kern/kern_conf.c:cdevsw_module_handler which calls for MOD_UNLOAD the function cdevsw_add(...,NULL,NULL) which unregisters our xxx_devsw! AFTERWARDS xxx_handler is asked if he wants to unload,...but it's too late...the xxx_devsw is gone, even for the case we don't want to unload! In my case: A program used a device and kldunload was called. xxx_handler returned EBUSY and kldunload said: can't unload, device busy. The next time the program issued a ioctl for the still open device the system crashed in spec_ioctl (gdb -k ...) with an invalid entry in the cdevsw for MYMAJOR: Fatal trap 12: page fault in kernel mode. >How-To-Repeat: see example above >Fix: /sys/kern/kern_conf.c:???devsw_module_handler should consult the module handler (data->chainevh) FIRST in the case of MOD_UNLOAD whether the module want's to unload before it "kills" the devsw! >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message