Linux modules version error "Invalid module format"

nicelhc13 picture nicelhc13 · May 20, 2015 · Viewed 7.7k times · Source

I made Linux external module and because my module need Linux kernel symbol,

I set the Modversion config and make it.(also did make modules_install)

My module was made exactly in lib/modules/(my linux)/extra/

But when I insert my module, shell prints error message

insmod: ERROR: could not insert module oxen_aggregator_module.ko: Invalid module format

This is dmesg contents

[  341.458351] oxen_aggregator_module: version magic '3.17.8-gentoo-r1 SMP mod_unload modversions ' should be '3.17.8-gentoo-r1 SMP mod_unload '

But I need modversions flag because if I didn't set that flag, Module.symvers have just 0x00000000 addresses.

Could you help me? How can I solve?

My Make file

SRCS    = oxen_aggregator_module.c
OBJS    = $(SRCS:.c=.o)

obj-m += $(OBJS)

KBUILD_EXTRA_SYMBOLS={/usr/src/linux-$(shell unamr -r)/Module.symvers}
all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules_install
clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
    $(RM) Module.markers modules.order

Answer

Tsyvarev picture Tsyvarev · Jun 1, 2015

You attempt to load module into kernel, for which it(module) hasn't be built. Or you build module for one kernel, but use KBUILD_EXTRA_SYMBOLS with Module.symvers file, created for another kernel.

If you need to use KBUILD_EXTRA_SYMBOLS with kernel's Module.symvers file, then it is definitely mess with different kernels somewhere.