Dumping the checksums in a module
Hello everyone,
I'm getting "disagrees about version of symbol struct_module" messages, and I'm trying to understand why.
As far as I understand (which is not very far), if I define CONFIG_MODVERSIONS, then checksums for various functions (all exported functions?) and various structures (which ones?) will be included inside the kernel image, and written to Module.symvers. When an out-of-tree module is built, it will also include these checksums.
How do I list the checksums within a module?
$ /sbin/modinfo -V module-init-tools version 3.2.2
$ uname -a Linux venus 2.6.18.6 #1 PREEMPT Thu Feb 8 18:04:49 CET 2007 i686 pentium4 i386 GNU/Linux
$ /sbin/modinfo test.ko filename: test.ko vermagic: 2.6.20.7-rt8 preempt mod_unload PENTIUMIII REGPARM depends: parm: pConfig_file:charp parm: allocator_himem:An integer (int) parm: EnableIdleMode:An integer (int) parm: Board_ID:An integer (int) parm: Diagnostic:An integer (int)
$ hexdump -C test.ko | grep -A2 struct_ 000752e0 17 98 07 0e 73 74 72 75 63 74 5f 6d 6f 64 75 6c |....struct_modul| 000752f0 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |e...............| 00075300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
I think this means that, in this module, the checksum for symbol struct_module is 0x1798070e, right?
Is there a simpler way to list all the checksums?
Regards.
Quoted 10 lines · John Sigler
I'm getting "disagrees about version of symbol
struct_module" messages, and I'm trying to understand why.As far as I understand (which is not very far), if I define
CONFIG_MODVERSIONS, then checksums for various functions (all exported functions?) and various structures (which ones?) will be included inside the kernel image, and written to Module.symvers. When an out-of-tree module is built, it will also include these checksums.
Quoted 3 lines
How do I list the checksums within a module?
Is there a simpler way to list all the checksums?
22:25 ichi:~ > modinfo aes
srcversion: 8CB82B3A254D5A950FD0D14
I think this one checksum is computed out of all functions that the module uses.
Jan
Quoted 14 lines · Jan Engelhardt
Quoted 12 lines · John Sigler
I'm getting "disagrees about version of symbol
struct_module" messages, and I'm trying to understand why.As far as I understand (which is not very far), if I define
CONFIG_MODVERSIONS, then checksums for various functions (all exported functions?) and various structures (which ones?) will be included inside the kernel image, and written to Module.symvers. When an out-of-tree module is built, it will also include these checksums.How do I list the checksums within a module?
Quoted 7 lines
Quoted 1 line
Is there a simpler way to list all the checksums?
22:25 ichi:~ > modinfo aes
srcversion: 8CB82B3A254D5A950FD0D14I think this one checksum is computed out of all functions that the module uses.
It is computed based on all files used for the module.
Check help for "Loadable module support | Source Checksum for all modules"
Sam
Quoted 12 lines · Jan Engelhardt
Quoted 11 lines · John Sigler
I'm getting "disagrees about version of symbol
struct_module" messages, and I'm trying to understand why.As far as I understand (which is not very far), if I define
CONFIG_MODVERSIONS, then checksums for various functions (all exported functions?) and various structures (which ones?) will be included inside the kernel image, and written to Module.symvers. When an out-of-tree module is built, it will also include these checksums.How do I list the checksums within a module?
Quoted 7 lines
Quoted 1 line
Is there a simpler way to list all the checksums?
22:25 ichi:~ > modinfo aes
srcversion: 8CB82B3A254D5A950FD0D14I think this one checksum is computed out of all functions that the module uses.
You've enabled MODULE_SRCVERSION_ALL which adds a checksum computed from the source files used to build a given module. What I want is to list ALL the checksums of the symbols included inside a given module.
e.g. for the kernel:
$ head Module.symvers 0x4da3749b firmware_unregister vmlinux EXPORT_SYMBOL_GPL 0xbf9d1364 generic_file_splice_write vmlinux EXPORT_SYMBOL 0x436417ac set_anon_super vmlinux EXPORT_SYMBOL 0x894bc434 kmem_cache_alloc vmlinux EXPORT_SYMBOL 0x1120b731 request_firmware vmlinux EXPORT_SYMBOL 0x0a2487e0 unblock_all_signals vmlinux EXPORT_SYMBOL 0x07d50a24 csum_partial vmlinux EXPORT_SYMBOL 0xcd6c78f9 __generic_unplug_device vmlinux EXPORT_SYMBOL 0x59ab4080 cap_bset vmlinux EXPORT_SYMBOL 0xee413334 softirq_preemption vmlinux EXPORT_SYMBOL [...]
config MODVERSIONS
bool "Module versioning support"
depends on MODULES
help
Usually, you have to use modules compiled with your kernel. Saying Y here makes it sometimes possible to use modules compiled for different kernels, by adding enough information to the modules to (hopefully) spot any changes which would make them incompatible with the kernel you are running. If unsure, say N.
config MODULE_SRCVERSION_ALL
bool "Source checksum for all modules"
depends on MODULES
help
Modules which contain a MODULE_VERSION get an extra "srcversion" field inserted into their modinfo section, which contains a sum of the source files which made it. This helps maintainers see exactly which source was used to build a module (since others sometimes change the module source without updating the version). With this option, such a "srcversion" field will be created for all modules. If unsure, say N.
Regards.
Quoted 14 lines · Sam Ravnborg
Quoted 13 lines · Jan Engelhardt
Quoted 12 lines · John Sigler
I'm getting "disagrees about version of symbol
struct_module" messages, and I'm trying to understand why.As far as I understand (which is not very far), if I define
CONFIG_MODVERSIONS, then checksums for various functions (all exported functions?) and various structures (which ones?) will be included inside the kernel image, and written to Module.symvers. When an out-of-tree module is built, it will also include these checksums.How do I list the checksums within a module?
Is there a simpler way to list all the checksums?
Quoted 8 lines
Quoted 5 lines
22:25 ichi:~ > modinfo aes
srcversion: 8CB82B3A254D5A950FD0D14I think this one checksum is computed out of all functions that the module uses.
It is computed based on all files used for the module.
Check help for "Loadable module support | Source Checksum for all modules"
How do I list *all* the checksums inside a given module?
For example, I want to know the checksum for "struct_module" in test.ko
$ grep struct_module Module.symvers 0x71d1e11f struct_module vmlinux EXPORT_SYMBOL
That's for the kernel.
$(MAGIC_COMMAND_TO_DUMP_CHECKSUMS) test.ko | grep struct_module => ...
Regards.
Quoted 6 lines · John Sigler
Quoted 6 lines
Quoted 2 lines
How do I list the checksums within a module?
Is there a simpler way to list all the checksums?22:25 ichi:~ > modinfo aes
srcversion: 8CB82B3A254D5A950FD0D14
Quoted 8 lines
Quoted 2 lines
I think this one checksum is computed out of all functions that the module uses.
You've enabled
MODULE_SRCVERSION_ALLwhich adds a checksum computed from the source files used to build a given module. What I want is to list ALL the checksums of the symbols included inside a given module.e.g. for the kernel:
for i in nm /lib/modules/2.6.18.8-ccj45-default/kernel/block/as-iosched.ko | grep " U " | cut -b 20-; do
grep '\b'"$i"'\b' Module.symvers;
done;
(for 32-bit, use cut -b 12-)
Jan
Quoted 12 lines · Jan Engelhardt
Quoted 11 lines · John Sigler
Quoted 7 lines
Quoted 2 lines
How do I list the checksums within a module?
Is there a simpler way to list all the checksums?22:25 ichi:~ > modinfo aes
srcversion: 8CB82B3A254D5A950FD0D14I think this one checksum is computed out of all functions that the module uses.
You've enabled
MODULE_SRCVERSION_ALLwhich adds a checksum computed from the source files used to build a given module. What I want is to list ALL the checksums of the symbols included inside a given module.
Quoted 8 lines
Quoted 1 line
e.g. for the kernel:
for i in
nm /lib/modules/2.6.18.8-ccj45-default/kernel/block/as-iosched.ko | grep " U " | cut -b 20-; dogrep '\b'"$i"'\b' Module.symvers;done;
(for 32-bit, use
cut -b 12-)
I think you didn't understand my request.
I have a *binary* kernel module that was compiled with CONFIG_MODVERSIONS enabled.
Thus, that binary module includes 32-bit (?) checksums for several kernel functions AND kernel structures.
cf. my original post:
$ hexdump -C test.ko | grep -A2 struct_ 000752e0 17 98 07 0e 73 74 72 75 63 74 5f 6d 6f 64 75 6c |....struct_modul| 000752f0 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |e...............| 00075300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
For example, the checksum for "struct_module" seems to be 0x1798070e.
Is there a tool (from linux-module-init-tools?) to list all the checksums included in a binary module.
Regards.