kld problem
Mauser
mauser at poczta.fm
Wed Jun 22 17:21:30 GMT 2005
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
#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysent.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/time.h>
#include <sys/timetc.h>
static int test_nw;
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_offset = NO_SYSCALL;
static struct sysent test_sysent = {
0, test_syscall
};
static int test_load(struct module *mod, int cmd, void *arg) {
if(cmd != MOD_LOAD && cmd != MOD_UNLOAD)
return EOPNOTSUPP;
return 0;
}
SYSCALL_MODULE(test,&test_offset,&test_sysent,test_load,NULL);
$ cat calltest.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/module.h>
#include <sys/syscall.h>
int main() {
struct module_stat stat;
stat.version = sizeof(stat);
modstat(modfind("test"),&stat);
return syscall(stat.data.intval);
}
We load the module, execute calltest, and within 15 seconds unload the
module. We get a kernel panic, because we removed the memory where our
test_syscall was located.
Currently I don't have any idea how to fix it, but it would be nice to
inform about this issue in manual.
Maciek
------------------------------------------------------------------
Kwiaty dla Taty..
Wyslij bukiet na Dzien Ojca.. >> http://link.interia.pl/f1897 <<
More information about the freebsd-hackers
mailing list