Date: Wed, 22 Jun 2005 16:52:58 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: Mauser <mauser@poczta.fm> Cc: freebsd-hackers@freebsd.org Subject: Re: kld problem Message-ID: <20050622215258.GE49171@dan.emsphone.com> In-Reply-To: <20050622192127.05bff1b8.mauser@poczta.fm> References: <20050622192127.05bff1b8.mauser@poczta.fm>
index | next in thread | previous in thread | raw e-mail
In the last episode (Jun 22), Mauser said:
> Unloading syscall kernel module can cause a system crash. It occurs when we
> unload the module while a process is executing our syscall. Example:
>
> $ cat kldtest.c
...
> static int test_syscall(struct thread *td, void *arg) {
> struct timeval tv;
> tv.tv_sec = 15;
> tv.tv_usec = 0;
> tsleep(&test_nw,PWAIT,"test",tvtohz(&tv));
> return 0;
> }
...
> static int test_load(struct module *mod, int cmd, void *arg) {
> if(cmd != MOD_LOAD && cmd != MOD_UNLOAD)
> return EOPNOTSUPP;
> return 0;
> }
In test_load, you can return a nonzero value on MOD_UNLOAD to abort an
unload request. See the module(9) manpage for more details. You may
need to increment a counter or hold a mutex while in the syscall to
make it easy for test_load to determine whether it's safe to unload or
not.
--
Dan Nelson
dnelson@allantgroup.com
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050622215258.GE49171>
