From owner-freebsd-current Sat Aug 22 19:56:10 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA09424 for freebsd-current-outgoing; Sat, 22 Aug 1998 19:56:10 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from smtp01.primenet.com (smtp01.primenet.com [206.165.6.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA09412 for ; Sat, 22 Aug 1998 19:56:03 -0700 (PDT) (envelope-from tlambert@usr04.primenet.com) Received: (from daemon@localhost) by smtp01.primenet.com (8.8.8/8.8.8) id TAA16964; Sat, 22 Aug 1998 19:55:19 -0700 (MST) Received: from usr04.primenet.com(206.165.6.204) via SMTP by smtp01.primenet.com, id smtpd016956; Sat Aug 22 19:55:17 1998 Received: (from tlambert@localhost) by usr04.primenet.com (8.8.5/8.8.5) id TAA20534; Sat, 22 Aug 1998 19:55:16 -0700 (MST) From: Terry Lambert Message-Id: <199808230255.TAA20534@usr04.primenet.com> Subject: Re: PEBCAK with modunload. To: bright@www.hotjobs.com (Alfred Perlstein) Date: Sun, 23 Aug 1998 02:55:16 +0000 (GMT) Cc: current@FreeBSD.ORG In-Reply-To: from "Alfred Perlstein" at Aug 21, 98 12:00:10 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > this might be fixed but i don't want to test it for obvious reasons. > > if you unload the linux emulator while linux programs are running you will > crash your box. (forgot i had x11amp running) Return non-zero from the LKM unload code in the module to veto unloading. > ~ % modunload -i 3 > Error: you have linux programs running. Specify -f to force. > (list of pids/commands passed back somehow from the lkm) Already possible to veto unload. The message is problematic, but can be implemented using a console message (kernel printf) for minimal function. > ~ % modunload -f -i 3 > Killing all linux programs running. > (list of pids follow, then the lkm is unloaded) Also possible, from within the kernel module, if you are willing to potentially hang the modunload in an ioctl on /dev/lkm (ie: a blocking device driver control to the lkm pseudo-device). This should not be a big problem, but it's a potential one. > the reason this would be nice is that you can get "inuse" errors and other > lkms can then refuse to unload unless told to forcfully do so. They could > then revoke access to files/devices they control for other lkms such as > filesystem lkms and device lkms. All LKM's are permitted to refuse unload. Whether or not they actually do so is implementation defined. The ability to crash the system is one of the reasons LKM twiddilng is limited to root credentialed processes. Busy system calls and filesystems are relatively trivial; the close being called only on last close of a device is problematic for resource tracking purposes, but if all you need is an "is everyone out of the pool?" mechanism, that's pretty trivial as well. I believe my sample LKM for system calls tracked usage an vetoed unload. To implement "drain", you need merely to disable the entry point, per the normal unload process, but not unload until the reference count goes to zero. This will require that you implement using a "generic" rather than a type-specific LKM type, to allow you to catch the vetoed unload request and actually prohibit future access to the device, system call, etc.. The normal semantics of a refusal to unload assume that the user space program wanting the unload will retry again later, and that subsequent reentry is not a problem. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message