insmod: ERROR: could not insert module HelloWorld.ko: Operation not permitted

12,302

So I had the same problem and this worked for me:

  1. You need to disable Secure Boot using mokutil use the first answer in this link

  2. Run the insmod command via sudo.

Good Luck.

Share:
12,302
kpk
Author by

kpk

4 years experienced software engineer with good experience in C,C++,Perl,Linux

Updated on July 26, 2022

Comments

  • kpk
    kpk almost 2 years

    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.