So, I was trying to install a hello world kernel shown the book "Linux Device Drivers" by Corbet, Jonathan.
This is the code for the file hello.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void) {
printk(KERN_ALERT "Hello World!!\n");
return 0;
}
static void hello_exit(void) {
printk(KERN_ALERT "Good Bye Module!!\n");
}
module_init(hello_init);
module_exit(hello_exit);
To build it, I use this makefile:
obj-m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
After running
make all
sudo insmod ./hello.ko
and I have the error
ERROR: could not insert module Operation not permitted
Installing a kernel space module with root privileges. Also tried
sudo su
sudo insmod ./hello.ko
Also tried
sudo modprove -v hello.ko
With similar error.