Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
"FATAL: invalid module format" and vermagic
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
wynn
Advocate
Advocate


Joined: 01 Apr 2005
Posts: 2416
Location: UK

PostPosted: Fri Oct 06, 2006 2:18 pm    Post subject: "FATAL: invalid module format" and vermagic Reply with quote

When the kernel loads a module it runs a check on it to make sure the module has not been compiled for a different version of the kernel or compiled with a different version of gcc.

The kernel developers say that if a mismatched module was loaded: "sooner or later you would get oopses and pollute the LKML with these hard to identify bogus reports. The same is true for minor differences in compiler, source version, preemption, calling conventions and so on, this is why these settings are checked on module loading."

It does this by comparing its own vermagic string with that of the module, the must match exactly, the same number of items and each item must be identical to the corresponding item in the other string, or else you get the "invalid module format" error.

This error will write a line to /var/log/messages something like
Code:
version magic '2.6.12-gentoo-r6 SMP preempt 586 4KSTACKS gcc-3.4' should be '2.6.12-gentoo-r6 SMP preempt 586 4KSTACKS gcc-3.3'
The first version magic string '2.6.12-gentoo-r6 SMP preempt 586 4KSTACKS gcc-3.4' is the module's and the second the kernel's.

The vermagic string for the module can also be displayed by
Code:
modinfo -F vermagic nvidia
which will give a result like
Code:
2.6.18-gentoo SMP preempt mod_unload PENTIUM4 gcc-4.1


NOTE: Another use for modinfo is to display the parameters which can be given to the module together with a brief description
Code:
modinfo ath-pci|grep parm
parm:           ath_debug:Load-time debug output enable (int)
parm:           autocreate:Create ath device in [sta|ap|wds|adhoc|ahdemo|monitor] mode. defaults to sta, use 'none' to disable (charp)
parm:           rfkill:Enable/disable RFKILL capability (int)
parm:           xchanmode:Enable/disable extended channel mode (int)
parm:           outdoor:Enable/disable outdoor use (int)
parm:           countrycode:Override default country code (int)


The vermagic string for the running kernel is a bit more difficult to display and must be picked out of the "Linux version" string which the kernel writes to /var/log/messages on starting
Quote:
Linux version 2.6.18-gentoo (root@lightfoot) (gcc version 4.1.1 (Gentoo 4.1.1)) #1 SMP PREEMPT Thu Sep 21 10:22:02 BST
2006
There you have the release, gcc version and two of the kernel parameters, but "PENTIUM4" and "mod_unload" don't appear.

Note that only the major and minor numbers of the gcc version are used in the comparison, that is, "gcc-4.1.1" matches "gcc-4.1" in the module vermagic string.

Since most of the "invalid format" errors are due to differing releases or gcc versions, this will probably be enough.

To get the full kernel vermagic, you will have to go to the kernel source, making sure it is exactly the same as it was when the running kernel was compiled (the date of the kernel in /boot and the date of /usr/src/linux/vmlinux should be, if not identical, very close).

Go to the kernel subdirectory and run
Code:
objdump -s module.o|grep -A 5 '2\.6\.'
which should give something like
Code:
0000 322e362e 31382d67 656e746f 6f20534d  2.6.18-gentoo SM
 0010 50207072 65656d70 74206d6f 645f756e  P preempt mod_un
 0020 6c6f6164 2050454e 5449554d 34206763  load PENTIUM4 gc
 0030 632d342e 31000000 00000000 00000000  c-4.1...........
 0040 06000000 00000000 02000000 01000000  ................
 0050 03000000 00000000 02000000 00000000  ................
the full kernel vermagic string.
_________________
The avatar is jorma, a "duck" from "Elephants Dream": the film and all the production materials have been made available under a Creative Commons Attribution 2.5 License, see orange.blender.org for details.
Back to top
View user's profile Send private message
mhoskins
n00b
n00b


Joined: 23 Jan 2004
Posts: 64
Location: Southern New Joisey

PostPosted: Fri Jan 05, 2007 5:40 am    Post subject: Vanilla-Sources difference Reply with quote

What do you do when your level best effort to make sure that all the pieces work together goes wide of the target? There are a buch of modules that are loaded like e1000, etc. and they all load with no complaint after a 'make modules_install' - no problem.

When I grep for the kernel version, this is what I get:

Code:

endor ~ $ sudo grep -i "linux version" /var/log/messages
Jan  4 22:17:14 endor sudo: mhoskins : TTY=pts/1 ; PWD=/usr/home/mhoskins ; USER=root ; COMMAND=/bin/grep -i linux version /var/log/messages


The response out of the messages file is the grep of the record of my use of 'sudo', and that is all that is there for the kernel. A strings on the kernel object shows nothing immediately obvious. But here is where the wierdness starts. I just compiled this kernel tonight. The gcc version to use is 4.1.1:

Code:

endor /usr/src/linux/kernel $ sudo gcc-config -l
 [1] i686-pc-linux-gnu-3.3.6
 [2] i686-pc-linux-gnu-3.3.6-hardened
 [3] i686-pc-linux-gnu-3.3.6-hardenednopie
 [4] i686-pc-linux-gnu-3.3.6-hardenednopiessp
 [5] i686-pc-linux-gnu-3.3.6-hardenednossp
 [6] i686-pc-linux-gnu-3.4.6
 [7] i686-pc-linux-gnu-3.4.6-hardened
 [8] i686-pc-linux-gnu-3.4.6-hardenednopie
 [9] i686-pc-linux-gnu-3.4.6-hardenednopiessp
 [10] i686-pc-linux-gnu-3.4.6-hardenednossp
 [11] i686-pc-linux-gnu-4.1.1 *


But the kernel directory modules.o shows something different. This is after a 'make clean' and a fresh make. The compile should be a 4.1.1 compiler, but the strings output shows gcc-3.4.

Code:

endor /usr/src/linux/kernel $ objdump -s module.o | grep -A 5 '2\.6'
 0000 322e362e 31372e31 33207072 65656d70  2.6.17.13 preemp
 0010 74206d6f 645f756e 6c6f6164 2050454e  t mod_unload PEN
 0020 5449554d 4d206763 632d332e 34000000  TIUMM gcc-3.4...
 0030 00000000 00000000 00000000 00000000  ................
 0040 06000000 00000000 02000000 01000000  ................
 0050 03000000 00000000 02000000 00000000  ................


The ath_hal.ko module object was compiled this evening as well and shows the 4.1 compiler. I don't understand how this is possible when the compiler has not been changed at all.

Code:

endor /lib/modules/2.6.17.13/net $ sudo modinfo -F vermagic ath_hal.ko
2.6.17.13 preempt mod_unload PENTIUMM gcc-4.1


What stupid, obvious thing am i missing here?
_________________
--
To know even one life has breathed easier because you have lived.
This is to have succeeded. -Bessie Stanely, 1905
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum