A kernel module create character device for process in user space read a random integer
Environment: Virtual Box with Ubuntu 18.04 (64 bit), kernel version 5.0.0-32-generic.
-
Open 2 terminal windows.
-
On the first terminal:
-
Compile
main.c
$ gcc -o main main.c
-
Build module
hung_chrdev
$ make
-
Insert moudule into Kernel.
$ sudo insmod hung_chrdev.ko
-
Run
main
$ ./main
-
-
On the second terminal: see messages on the logging.
$ sudo dmesg -c $ sudo dmesg -wH
-
Remove module from kernel on the first terminal.
$ sudo rmmod hung_chrdev
A kernel module hooking onto sys_write and sys_open.
Created in Zorin 12.4 on 64 bit, with kernel version 4.15.0-30-generic.
-
Open 2 terminals.
-
On the first terminal:
-
Compile
test.c
.$ gcc test.c -o test
-
Compile module
hook
.$ make
-
Insert moudule into Kernel.
$ sudo insmod hook.ko
-
Run
test
.$ ./test
-
-
On the second terminal: see messages on the logging.
$ sudo dmesg -c $ sudo dmesg -wH
-
Remove module from kernel on the first terminal.
$ rm hook