diff options
-rw-r--r-- | driver/Kbuild | 3 | ||||
-rw-r--r-- | driver/ks_def_handler.c | 39 | ||||
-rw-r--r-- | driver/ks_def_handler.h | 20 | ||||
-rw-r--r-- | driver/probes_manager.c | 31 | ||||
-rw-r--r-- | driver/probes_manager.h | 3 | ||||
-rw-r--r-- | driver/storage.c | 1 | ||||
-rw-r--r-- | driver/storage.h | 1 |
7 files changed, 63 insertions, 35 deletions
diff --git a/driver/Kbuild b/driver/Kbuild index 33003e87..2ebe6828 100644 --- a/driver/Kbuild +++ b/driver/Kbuild @@ -4,4 +4,5 @@ obj-m := swap_driver.o swap_driver-y := error_storage.o device_driver.o ec.o legacy.o module.o probes.o \ probes_manager.o storage.o us_proc_inst.o helper.o us_slot_manager.o \ sspt/ip.o sspt/sspt_page.o sspt/sspt_file.o sspt/sspt_proc.o \ - filters/filters_core.o filters/filter_by_pach.o us_def_handler.o + filters/filters_core.o filters/filter_by_pach.o us_def_handler.o \ + ks_def_handler.o diff --git a/driver/ks_def_handler.c b/driver/ks_def_handler.c new file mode 100644 index 00000000..8a88ad1c --- /dev/null +++ b/driver/ks_def_handler.c @@ -0,0 +1,39 @@ +#include <linux/module.h> +#include <asm/percpu.h> +#include "probes_manager.h" + +DEFINE_PER_CPU(kernel_probe_t *, gpKernProbe) = NULL; +EXPORT_PER_CPU_SYMBOL_GPL(gpKernProbe); + +unsigned long def_jprobe_event_pre_handler(kernel_probe_t *p, + struct pt_regs *regs) +{ + __get_cpu_var(gpKernProbe) = p; + + return 0; +} +EXPORT_SYMBOL_GPL(def_jprobe_event_pre_handler); + +void def_jprobe_event_handler(unsigned long arg0, unsigned long arg1, + unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + kernel_probe_t *p = __get_cpu_var(gpKernProbe); + + pack_event_info(KS_PROBE_ID, RECORD_ENTRY, "pxxxxxx", p->addr, + arg0, arg1, arg2, arg3, arg4, arg5); + dbi_jprobe_return(); +} +EXPORT_SYMBOL_GPL(def_jprobe_event_handler); + +int def_retprobe_event_handler(struct kretprobe_instance *ri, + struct pt_regs *regs, kernel_probe_t *p) +{ + int ret_val; + + ret_val = regs_return_value(regs); + pack_event_info(KS_PROBE_ID, RECORD_RET, "pd", p->addr, ret_val); + + return 0; +} +EXPORT_SYMBOL_GPL(def_retprobe_event_handler); diff --git a/driver/ks_def_handler.h b/driver/ks_def_handler.h new file mode 100644 index 00000000..050f8c72 --- /dev/null +++ b/driver/ks_def_handler.h @@ -0,0 +1,20 @@ +#ifndef _KS_DEF_HANDLER_H +#define _KS_DEF_HANDLER_H + +#include <asm/percpu.h> +#include "probes_manager.h" + +struct pt_regs; +struct kretprobe_instance; + +DECLARE_PER_CPU(kernel_probe_t *, gpKernProbe); + +unsigned long def_jprobe_event_pre_handler(kernel_probe_t *p, + struct pt_regs *regs); +void def_jprobe_event_handler(unsigned long arg0, unsigned long arg1, + unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5); +int def_retprobe_event_handler(struct kretprobe_instance *ri, + struct pt_regs *regs, kernel_probe_t *p); + +#endif /* _KS_DEF_HANDLER_H */ diff --git a/driver/probes_manager.c b/driver/probes_manager.c index cfce4cec..cd8897cd 100644 --- a/driver/probes_manager.c +++ b/driver/probes_manager.c @@ -170,37 +170,6 @@ int reset_probes(void) return 0; } -static DEFINE_PER_CPU(kernel_probe_t *, gpKernProbe) = NULL; - -unsigned long -def_jprobe_event_pre_handler (kernel_probe_t * probe, struct pt_regs *regs) -{ - __get_cpu_var (gpKernProbe) = probe; - - return 0; -} - -void -def_jprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6) -{ - //static int nCount; - kernel_probe_t *probe = __get_cpu_var(gpKernProbe); - - pack_event_info(KS_PROBE_ID, RECORD_ENTRY, "pxxxxxx", probe->addr, arg1, arg2, arg3, arg4, arg5, arg6); - dbi_jprobe_return (); -} - -int -def_retprobe_event_handler (struct kretprobe_instance *pi, struct pt_regs *regs, kernel_probe_t * probe) -{ - int ret_val; - - ret_val = regs_return_value(regs); - pack_event_info(KS_PROBE_ID, RECORD_RET, "pd", probe->addr, ret_val); - - return 0; -} - int install_kern_otg_probe(unsigned long addr, unsigned long pre_handler, unsigned long jp_handler, diff --git a/driver/probes_manager.h b/driver/probes_manager.h index 4f0cff4f..9cf1226a 100644 --- a/driver/probes_manager.h +++ b/driver/probes_manager.h @@ -37,9 +37,6 @@ extern int reset_probes(void); int set_kernel_probes(void); int unset_kernel_probes(void); -extern unsigned long def_jprobe_event_pre_handler (kernel_probe_t * probe, struct pt_regs *regs); -extern void def_jprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6); -extern int def_retprobe_event_handler (struct kretprobe_instance *probe, struct pt_regs *regs, kernel_probe_t * p); void dbi_install_user_handlers(void); void dbi_uninstall_user_handlers(void); int install_kern_otg_probe(unsigned long addr, diff --git a/driver/storage.c b/driver/storage.c index d402a074..3db2c030 100644 --- a/driver/storage.c +++ b/driver/storage.c @@ -30,6 +30,7 @@ #include "CProfile.h" #include "sspt/sspt.h" #include "sspt/sspt_debug.h" +#include "ks_def_handler.h" #define after_buffer ec_info.buffer_size diff --git a/driver/storage.h b/driver/storage.h index 5384ff7f..df34b09a 100644 --- a/driver/storage.h +++ b/driver/storage.h @@ -22,6 +22,7 @@ #include <linux/module.h> #include <linux/list.h> #include <linux/spinlock.h> +#include <dbi_kprobes.h> #include "picl.h" #include "ec_ioctl.h" #include "ec_probe.h" |