49 lines
2.6 KiB
C
49 lines
2.6 KiB
C
#include <linux/kprobes.h>
|
|
|
|
// for diag_kallsyms_lookup_name
|
|
extern unsigned long (*diag_kallsyms_lookup_name)(const char *name);
|
|
extern struct kprobe kprobe_kallsyms_lookup_name;
|
|
|
|
// int fn_kallsyms_lookup_name_init(void); // init kallsyms_lookup_name
|
|
|
|
// form
|
|
// https://github.com/alibaba/diagnose-tools/blob/8cd905a1c17f2201e460a2d607413a1303757a32/SOURCE/module/internal.h#L65
|
|
// look for current function address, all the function with prefix "orig_" are
|
|
#define LOOKUP_SYMS(name) \
|
|
do { \
|
|
orig_##name = (void *)diag_kallsyms_lookup_name(#name); \
|
|
if (!orig_##name) { \
|
|
printk(KERN_ERR "kallsyms_lookup_name: %s\n", #name); \
|
|
return -EINVAL; \
|
|
} \
|
|
} while (0)
|
|
|
|
#define LOOKUP_SYMS_NORET(name) \
|
|
do { \
|
|
orig_##name = (void *)diag_kallsyms_lookup_name(#name); \
|
|
if (!orig_##name) \
|
|
pr_err("kallsyms_lookup_name: %s\n", #name); \
|
|
} while (0)
|
|
|
|
int init_orig_fun(void);
|
|
|
|
// All the function with prefix "orig_X" are
|
|
// LOOKUP_SYMS(X);
|
|
extern unsigned int (*orig_stack_trace_save_tsk)(struct task_struct *task,
|
|
unsigned long *store,
|
|
unsigned int size,
|
|
unsigned int skipnr);
|
|
extern void (*orig_show_stack)(struct task_struct *task, unsigned long *sp,
|
|
const char *loglvl); // output kernel stack
|
|
extern struct sched_class *orig_idle_sched_class; // idle process
|
|
extern int (*orig_get_task_type)(struct sched_entity *se);
|
|
extern int (*orig_kernfs_name)(struct kernfs_node *kn, char *buf,
|
|
size_t buflen); // get sysfs name
|
|
extern int (*orig_access_remote_vm)(
|
|
struct mm_struct *mm, unsigned long addr, void *buf, int len,
|
|
unsigned int gup_flags); // read remote memory
|
|
extern struct task_struct *(*orig_find_task_by_vpid)(
|
|
pid_t nr); // find task by pid
|
|
|
|
extern void (*orig_open_softirq)(int nr, void (*action)(struct softirq_action *));
|
|
extern void (*orig_raise_softirq)(unsigned int nr); |