• Uncategorized

About linux-kernel : What-will-happen-if-two-kernel-module-export-same-symbol

Question Detail

If two kernel module contain EXPORT_SYMBOL(a), a is defined as: int a, what will happen if two module was inserted? which “a” will be used?

Question Answer

You can’t insert duplicate symbols into the kernel. Example:

The xor module loaded in my kernel

[email protected]:~$ lsmod | grep xor
xor                     4685  1 async_xor

The exported xor_blocks symbol in the xor module

[email protected]:~$ nm /lib/modules/2.6.32-24-generic/kernel/crypto/xor.ko  | grep xor_blocks
0000000000000000 r __kcrctab_xor_blocks
0000000000000000 r __kstrtab_xor_blocks
0000000000000000 r __ksymtab_xor_blocks
0000000000000bb0 T xor_blocks

Another exported xor_blocks symbol in a module I created

[email protected]:~$ nm mod-t1.ko  | grep xor
0000000000000000 r __kcrctab_xor_blocks
0000000000000000 r __kstrtab_xor_blocks
0000000000000000 r __ksymtab_xor_blocks
0000000000000000 T xor_blocks

Error reported from insmod

[email protected]:~$ sudo insmod mod-t1.ko 
insmod: error inserting 'mod-t1.ko': -1 Invalid module format

Duplicate error message from dmesg

[422002.174033] mod_t1: exports duplicate symbol xor_blocks (owned by xor)

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.