Skip to content

Instantly share code, notes, and snippets.

@linuxthor
Created September 11, 2020 21:55
Show Gist options
  • Save linuxthor/a2b2ef9e39470fd6dd188b25c427322b to your computer and use it in GitHub Desktop.
Save linuxthor/a2b2ef9e39470fd6dd188b25c427322b to your computer and use it in GitHub Desktop.
Use a kprobe to find the address of some kernel symbol
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/kprobes.h>
static struct kprobe kp = {
.symbol_name = "kallsyms_lookup_name"
};
int init_module(void)
{
register_kprobe(&kp);
printk("Found at %px \n", kp.addr);
return 0;
}
void cleanup_module(void)
{
unregister_kprobe(&kp);
}
MODULE_AUTHOR("linuxthor");
MODULE_LICENSE("GPL");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment