Cannot access symbols in /proc/kallsyms from systemtap script in guru mode.

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux

Issue

  • Cannot access symbols in /proc/kallsyms from systemtap script in guru mode.
# stap -gk bug.stp 
WARNING: "cgroup_unlock" [/tmp/stapfC554g/stap_14223.ko] undefined!
WARNING: "cgroup_lock" [/tmp/stapfC554g/stap_14223.ko] undefined!
Error inserting module '/tmp/stapfC554g/stap_14223.ko': Unknown symbol in module
Error, 'stap_14223' is not a zombie systemtap module.

Resolution

Need to check if the symbol is exported before using it in systemtap. For every exported symbol there will be another symbol with __ksymtab prefixed.

For example, for printk.

ffffffff814fd1e2 T printk
ffffffff81812550 r __ksymtab_printk

Root Cause

/proc/kallsyms displays all global symbols.
Symbols are exported using EXPORT_SYMBOL or EXPORT_SYMBOL_GPL in kernel code.
Symbols like cgroup_unlock and cgroup_lock are global, but they are not exported using EXPORT_SYMBOL or EXPORT_SYMBOL_GPL.

Only exported symbols are labeled as "global" in the context of kernel. So systemtap can only use symbols exported using EXPORT_SYMBOL or EXPORT_SYMBOL_GPL.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments