crash: sysctls in dependend modules crash machine
Bjoern A. Zeeb
bzeeb-lists at lists.zabbadoz.net
Mon May 31 10:46:08 PDT 2004
Hi,
let's say module a defines a new sysctl node (SYSCTL_DECL
in shared header file):
--- cut a.c ---
SYSCTL_NODE (, OID_AUTO, testsysctl, CTLFLAG_RW, 0, "Test kld dependend sysctls");
SYSCTL_NODE(_testsysctl, OID_AUTO, modulea, CTLFLAG_RW, 0, "module a");
int a = 1;
SYSCTL_INT(_testsysctl_modulea, OID_AUTO, a, CTLFLAG_RW, &a, 0, "a");
--- / a.c ---
and module b depends on module a and adds following:
--- cut b.c ---
SYSCTL_NODE(_testsysctl, OID_AUTO, moduleb, CTLFLAG_RW, 0, "module b");
int b = 1;
SYSCTL_INT(_testsysctl_moduleb, OID_AUTO, b, CTLFLAG_RW, &b, 0, "b");
--- / b.c ---
loading module a will work:
noc# kldload -v ./test_sysctl_base.ko
test_sysctl_base KLD loaded.
Loaded ./test_sysctl_base.ko, id=4
noc# kldstat
Id Refs Address Size Name
1 2 0xffffffff80100000 830ad8 kernel
4 1 0xffffffff98d76000 2c7 test_sysctl_base.ko
BUT:
loading module b will crash the machine:
noc# cd ../b/
noc# kldload -v ./test_sysctl_b.ko
(handwritten bt):
sysctl_find_oidname+0x14
sysctl_register_oid+0x19
linker_file_register_sysctls+0x3c
linker_load_file+0xe7
linker_load_module+0xd8
kldload+0xf3
sysctl+0x358
...
To reproduce you can find two quickly hacked up sample modules at
http://sources.zabbadoz.net/freebsd/amd64/amd64-modules-sysctl.tbz
tar xjvf amd64-modules-sysctl.tbz
cd amd64-modules-sysctl/a
make
su
kldload -v ./test_sysctl_base.ko
exit
kldstat
cd ../b
make
su
echo "be sure to mount your partitions ro now; I will crash"
mount -u -o ro ... /usr /
kldload -v ./test_sysctl_b.ko
--
Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT
More information about the freebsd-amd64
mailing list