Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

module_layout version incompatibility

I try to insmod a linux kernel legacy module being ported by me. The following errors appear:

> sudo insmod camac-mx.ko
insmod: error inserting 'camac-mx.ko': -1 Invalid module format
dmesg |tail -n 1
[1312783.938299] camac_mx: disagrees about version of symbol module_layout

How do I fix this?

like image 838
Basilevs Avatar asked Apr 27 '10 09:04

Basilevs


3 Answers

This indicates you have compiled the module against a different version of the kernel than is running. Note that even if the running kernel and kernel source have the same numerical value (e.g. both are 2.6.31-20-server), if the two use different configuration options, you may see this error. Also check if there are multiple versions of this module on the machine and ensure you are loading the correct one.

like image 178
ctuffli Avatar answered Oct 07 '22 07:10

ctuffli


For those working on systems without access to kernel, kernel-config or ksyms, if you have a working.ko and your built, non-working, broken.ko.

Chances are it probably will not load, but if you are desperate enough to try;

# modprobe --dump-modversions working.ko
0x0b11e775      module_layout
# modprobe --dump-modversions broken.ko
0x2719d41e      module_layout

Then using your favourite hex editor, change it to match:

00016c70  75 e7 11 0b 6d 6f 64 75  6c 65 5f 6c 61 79 6f 75  |u...module_layou|

(Value is in reverse due to endian ordering) There will most likely be a whole bunch you have to match. Someone could write a perl script to do this....

like image 19
lundman Avatar answered Oct 07 '22 06:10

lundman


To resolve that (was hard).

First, you need kernel sources and headers.

Go to your kernel base dir, here /usr/src/linux-source-2.6.35

Check uname -r , here 2.6.35-27-generic

make -C /lib/modules/2.6.35-27-generic/build \
SUBDIRS=/usr/src/linux-source-2.6.35/drivers/net/wireless/ath/ath5k modules

/lib/modules/2.6.35-27-generic/build -> /usr/src/linux-headers-2.6.35-27-generic

Check the module dependencies with modinfo or lsmod and load them in a script :

modprobe -r ath5k
modprobe cfg80211
modprobe led_class
modprobe mac80211
modprobe ath
insmod /usr/src/linux-source-2.6.35/drivers/net/wireless/ath/ath5k/ath5k.ko

With this method, vermagic could also be different.... the make modules_install was useless, but maybe because modules are present in 2 different places (/lib/modules/extra and .../kernel/drivers), not replaced...

modinfo -F vermagic /usr/src/linux-source-2.6.35/drivers/net/wireless/ath/ath5k/ath5k.ko

I dont really understand why it's so difficult in ubuntu 10.10 to fix/debug a module :(

like image 8
Tanguy Avatar answered Oct 07 '22 08:10

Tanguy