This shows you the differences between two versions of the page.
isc:labs:kernel:tasks:02 [2021/11/26 11:07] radu.mantu |
isc:labs:kernel:tasks:02 [2022/10/08 22:05] (current) radu.mantu [02. [??p] Kernel modules] |
||
---|---|---|---|
Line 6: | Line 6: | ||
<code bash> | <code bash> | ||
- | $ lsmod | + | [student@host]$ lsmod |
ecdh_generic 16384 1 bluetooth | ecdh_generic 16384 1 bluetooth | ||
- | $ modinfo ecdh_generic | grep description | + | [student@host]$ modinfo ecdh_generic | grep description |
description: ECDH generic algorithm | description: ECDH generic algorithm | ||
- | $ modinfo bluetooth | grep description | + | [student@host]$ modinfo bluetooth | grep description |
description: Bluetooth Core ver 2.22 | description: Bluetooth Core ver 2.22 | ||
</code> | </code> | ||
Line 24: | Line 24: | ||
Now, let's compile our module, upload it into the kernel, and see what happens: | Now, let's compile our module, upload it into the kernel, and see what happens: | ||
<code bash> | <code bash> | ||
- | $ make | + | [student@host]$ make |
- | $ sudo insmod test.ko | + | [student@host]$ sudo insmod test.ko |
- | $ sudo dmesg | + | [student@host]$ sudo dmesg |
... | ... | ||
[ 6348.461247] my-first-module: Hello world! | [ 6348.461247] my-first-module: Hello world! | ||
- | $ sudo rmmod test | + | [student@host]$ sudo rmmod test |
- | $ sudo dmesg | + | [student@host]$ sudo dmesg |
... | ... | ||
[ 6348.461247] my-first-module: Hello world! | [ 6348.461247] my-first-module: Hello world! | ||
Line 176: | Line 176: | ||
[root@guest]$ cat /proc/modules | [root@guest]$ cat /proc/modules | ||
test 20480 1 - Loading 0xffffffffc0304000 (O+) | test 20480 1 - Loading 0xffffffffc0304000 (O+) | ||
+ | </code> | ||
+ | |||
+ | In this case, the best course of action is to simply reboot, but if you want to risk it, just run ''rmmod -f'' to force unloading the module. Be warned that this is very dangerous. Also, if the module is still there after using the ''-f'' flag, make sure that //CONFIG_MODULE_FORCE_UNLOAD// was set at compile time. | ||
+ | |||
+ | <code bash> | ||
+ | # check if force unloading the module is an option | ||
+ | [root@guest]$ zcat /proc/config.gz | grep CONFIG_MODULE_FORCE_UNLOAD | ||
+ | CONFIG_MODULE_FORCE_UNLOAD=y | ||
+ | |||
+ | # force unload the kernel module | ||
+ | [root@guest]$ rmmod -f test | ||
</code> | </code> | ||
</note> | </note> | ||