How to get the address of the kernel module that was inserted using insmod?

I would like to know the address of the kernel module. In fact, the stack trace shows that the accident was caused from the kernel module (which was inserted into the system after the system booted). There are several modules that I manually insert. Therefore, I need to determine which of these modules triggers the trigger. Please let me know how to get the address of each module loaded with insmod.

+7
source share
3 answers

cat /proc/modules should give you a rough guide on loading things. You can get more information about exactly where the kernel crash occurred by looking at /proc/kallsyms .

+7
source

/sys/module/<MODULE_NAME>/sections/ contains the addresses of all sections of your module. Since most sections start with a period ( . ), Remember to pass -a to ls when listing this directory contents:

 $ ls -a /sys/module/usbcore/sections/ . __ex_table __param .. .fixup .rodata .altinstr_replacement .gnu.linkonce.this_module .rodata.str1.1 .altinstructions .init.text .rodata.str1.8 .bss __kcrctab_gpl .smp_locks __bug_table __ksymtab_gpl .strtab .data __ksymtab_strings .symtab .data..read_mostly __mcount_loc .text .data.unlikely .note.gnu.build-id .text.unlikely .exit.text .parainstructions __verbose 
+3
source

pr_debug on dmesg

If we pr_debug , then it shows the base address to which the module was loaded.

This can be useful, for example, if a module panics in init_module , and you cannot read /proc/modules interactively.

The best way to enable pr_debug is to compile the kernel with CONFIG_DYNAMIC_DEBUG=y , as described in: Why doesn't the Linux kernel pr_debug give any output?

Then when you do:

 echo 8 > /proc/sys/kernel/printk echo 'file kernel/module.c +p' > /sys/kernel/debug/dynamic_debug/control insmod mymodule.ko 

we see a line of the form:

 0xffffffffc0005000 .text 

which contains the base address.

0
source

All Articles