Issue
I am trying to learn linux and kernel development.
I am able to build the module but am unable to load it.
HelloWorld.c
/*
* hello-1.c - The simplest kernel module.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
And here is my make file:
KERNEL_SOURCE := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
obj-m += HelloWorld.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
while doing insmod for loading the module permission is getting denied. I tried even doing it with root and also with modprobe, but no use.
I also tried Link but issue still the same.
Hope i get some help. I am using ubuntu 18.04LTS.
Solution
So I had the same problem and this worked for me:
You need to disable Secure Boot using mokutil use the first answer in this link
Run the insmod command via sudo.
Good Luck.
Answered By - YanBir Answer Checked By - Clifford M. (WPSolving Volunteer)