1

How can I get the base address and size of a loaded kernel module?

3

I think you can use /proc/modules. It contains information about all currently loaded modules in the kernel. For example:

cat /proc/modules | grep i8k

Result could be:

i8k 14696 0 - Live 0xffffffffa03b8000

Where:

  1. The first column contains the name of the module.
  2. The second column refers to the memory size of the module, in bytes.
  3. The third column lists how many instances of the module are currently loaded. A value of zero represents an unloaded module.
  4. The fourth column states if the module depends upon another module to be present in order to function, and lists those other modules.
  5. The fifth column lists what load state the module is in: Live, Loading, or Unloading.
  6. Base memory address for a module in the kernel's virtual address space.

If you run:

awk '$1 ~ /i8k/ { print $1, $2, $6 }' /proc/modules

The result could be, values you need:

i8k 14696 0xffffffffa03b8000
1

Size on /sys

I like this alternative as it gives just a single value:

cat /sys/module/<module-name>/coresize

Load address on pr_debug

If you enable pr_debug, that information is present, and this can be useful if the module panics at init_module.

Details at: How to get the address of a kernel module that was inserted using insmod? | Stack Overflow

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.