M
M
mtrue2016-01-25 15:18:57
Debian
mtrue, 2016-01-25 15:18:57

Why does the simplest linux kernel module break with an Invalid parameters error when loading insmod?

I'm trying to build and load the simplest hello world module for the linux kernel into the kernel. Compilation succeeds, but here insmod constantly breaks down with an error message:

$ sudo insmod hello.ko
insmod: ERROR: could not insert module hello.ko: Invalid parameters

But there are no parameters in my module :(
I tried a million different hello worlds, and which use /proc, and printk, and even /dev. Still the same result - Invalid parameters.
My environment:
$ uname -r
3.16.0-4-amd64

I have set all possible kernel headers:
linux-headers-3.16.0-4-all
linux-headers-3.16.0-4-all-amd64
linux-headers-3.16.0-4-amd64
linux-headers-3.16.0-4-common
linux-headers- amd64

Module code:
#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");
    return 0;
}

void cleanup_module(void)
{
    printk(KERN_INFO "Goodbye world 1.\n");
}

MODULE_LICENSE("GPL");

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

Output of the `make` command:
make -C /lib/modules/3.16.0-4-amd64/build M=/home/user/c.driver/driver-1 modules
make[1]: Entering directory '/usr/src/linux-headers-3.16 .0-4-amd64'
Makefile:10: *** mixed implicit and normal rules: deprecated syntax
make[1]: Entering directory `/usr/src/linux-headers-3.16.0-4-amd64'
CC [M ] /home/user/c.driver/driver-1/hello.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/user/c.driver/driver-1/hello.mod.o
LD [M] / home/user/c.driver/driver-1/hello.ko
make[1]: Leaving directory '/usr/src/linux-headers-3.16.0-4-amd64'

UPD: The situation is similar with Ubuntu 14.04.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question