diff options
Diffstat (limited to 'driver')
-rw-r--r-- | driver/module.c | 2 | ||||
-rw-r--r-- | driver/module.h | 2 | ||||
-rwxr-xr-x | driver/patchko.sh | 36 | ||||
-rw-r--r-- | driver/probes_manager.c | 2 | ||||
-rw-r--r-- | driver/sspt/sspt.h | 8 | ||||
-rw-r--r-- | driver/storage.c | 5 | ||||
-rw-r--r-- | driver/us_proc_inst.c | 27 | ||||
-rw-r--r-- | driver/us_proc_inst.h | 14 |
8 files changed, 53 insertions, 43 deletions
diff --git a/driver/module.c b/driver/module.c index ee44c3d6..c74dc82a 100644 --- a/driver/module.c +++ b/driver/module.c @@ -62,8 +62,6 @@ void __put_task_struct(struct task_struct *tsk) void (*flush_cache_page) (struct vm_area_struct * vma, unsigned long page); #endif -#include "../../tools/gpmu/probes/entry_data.h" - storage_arg_t sa_dpf; static int __init InitializeModule(void) diff --git a/driver/module.h b/driver/module.h index fe774720..22fc12e6 100644 --- a/driver/module.h +++ b/driver/module.h @@ -71,9 +71,11 @@ #include "device_driver.h" #include "probes_manager.h" #include "probes.h" +#include "../../tools/gpmu/probes/entry_data.h" extern char *device_name; extern unsigned int device_major; +extern storage_arg_t sa_dpf; struct handler_map { unsigned long func_addr; diff --git a/driver/patchko.sh b/driver/patchko.sh index 453debe2..b5267c6d 100755 --- a/driver/patchko.sh +++ b/driver/patchko.sh @@ -47,8 +47,8 @@ if [ -f "$patch_file" ]; then cp -f "${patch_file}" "${output_file}" #get patching adderes - let pos=`cat $patch_file.addr | awk '{print \$1}'` - let abs_len=`cat $patch_file.addr | awk '{print \$2}'` + pos=$((`cat $patch_file.addr | awk '{print \$1}'`)) + abs_len=$((`cat $patch_file.addr | awk '{print \$2}'`)) key_before=`dd if="$patch_file" bs=1 skip=${pos}c count=${abs_len}c 2>/dev/null` debug "key_before<$key_before>" @@ -57,7 +57,7 @@ if [ -f "$patch_file" ]; then echo -ne "`cat $data_file` $key_before_tail\000">$data_file key_len="`cat $data_file`" - let key_len=${#key_len}+1 + key_len=$((${#key_len}+1)) debug "POS>$pos<" debug "OLDLEN>$abs_len<" @@ -95,24 +95,24 @@ if [ -f "$patch_file" ]; then exit 1 fi - let file_size=`ls -la "$patch_file" | awk '{print \$5}'` + file_size=$((`ls -la "$patch_file" | awk '{print \$5}'`)) debugmk "file_size=$file_size" section=`$readelf -e $patch_file | grep ${sect_name}` section=${section##*${sect_name}} debugmk "section=$section" - let addr=0x`echo $section | awk '{print $2}'` - let offs=0x`echo $section | awk '{print $3}'` - let size=0x`echo $section | awk '{print $4}'` + addr=$((0x`echo $section | awk '{print $2}'`)) + offs=$((0x`echo $section | awk '{print $3}'`)) + size=$((0x`echo $section | awk '{print $4}'`)) debugmk $addr:$offs:$size - let abs_len=0x`$objdump -t -j .${sect_name} "$patch_file" | grep _${varname} | awk '{print $5}'` - let abs_len=$abs_len-${#varname}-1 - let sect_off=0x`$objdump -t -j .${sect_name} "$patch_file" | grep _${varname} | awk '{print $1}'` - let add_off=${#varname}+1 + abs_len=$((0x`$objdump -t -j .${sect_name} "$patch_file" | grep _${varname} | awk '{print $5}'`)) + abs_len=$(($abs_len-${#varname}-1)) + sect_off=$((0x`$objdump -t -j .${sect_name} "$patch_file" | grep _${varname} | awk '{print $1}'`)) + add_off=$((${#varname}+1)) - let abs_addr=${addr}+${offs}+${sect_off}+${add_off} + abs_addr=$((${addr}+${offs}+${sect_off}+${add_off})) debugmk "abs_addr=$abs_addr;" debugmk "abs_len=$abs_len" if [ "$opt" = "-r" ];then @@ -124,7 +124,15 @@ if [ -f "$patch_file" ]; then #gen file version (use only on host) debugmk "Generate version data for <$patch_file>" #res=`dd if="$patch_file" of="$patch_file.addr" bs=1 skip=${abs_addr}c count=${abs_len}c` - echo "$abs_addr $abs_len">"$patch_file.addr" + if [ "$abs_addr" = "" ];then + debugmk "ERROR cannot get absolute addres of module info line for patching" + exit 253 + elif [ "$abs_len" = "" ];then + debugmk "ERROR cannot get length of module info line for patching" + exit 252 + else + echo "$abs_addr $abs_len">"$patch_file.addr" + fi debugmk "patch_addr=`cat $patch_file.addr`" else error "Wrong param <$opt>" @@ -132,4 +140,4 @@ if [ -f "$patch_file" ]; then fi else error "file for patchig not found <$patch_file>" -fi + fi diff --git a/driver/probes_manager.c b/driver/probes_manager.c index a037d2a2..cb17ac59 100644 --- a/driver/probes_manager.c +++ b/driver/probes_manager.c @@ -394,7 +394,7 @@ remove_probe (unsigned long addr) return result; } -DEFINE_PER_CPU(kernel_probe_t *, gpKernProbe) = NULL; +static DEFINE_PER_CPU(kernel_probe_t *, gpKernProbe) = NULL; unsigned long def_jprobe_event_pre_handler (kernel_probe_t * probe, struct pt_regs *regs) diff --git a/driver/sspt/sspt.h b/driver/sspt/sspt.h index 1092a6cc..e11be73a 100644 --- a/driver/sspt/sspt.h +++ b/driver/sspt/sspt.h @@ -30,6 +30,7 @@ #include "sspt_file.h" #include "sspt_procs.h" #include "sspt_debug.h" +#include "../us_proc_inst.h" #include "../storage.h" @@ -96,15 +97,12 @@ enum US_FLAGS { US_DISARM }; -static int register_usprobe(struct task_struct *task, struct us_ip *ip, int atomic); -static int unregister_usprobe(struct task_struct *task, struct us_ip *ip, int atomic, int no_rp2); - -static int register_usprobe_my(struct task_struct *task, struct us_ip *ip) +static inline int register_usprobe_my(struct task_struct *task, struct us_ip *ip) { return register_usprobe(task, ip, 1); } -static int unregister_usprobe_my(struct task_struct *task, struct us_ip *ip, enum US_FLAGS flag) +static inline int unregister_usprobe_my(struct task_struct *task, struct us_ip *ip, enum US_FLAGS flag) { int err = 0; diff --git a/driver/storage.c b/driver/storage.c index ebb44055..5f770efb 100644 --- a/driver/storage.c +++ b/driver/storage.c @@ -243,7 +243,8 @@ EXPORT_SYMBOL_GPL(us_proc_info); EXPORT_SYMBOL_GPL(dex_proc_info); typedef void *(*get_my_uprobes_info_t)(void); #ifdef MEMORY_CHECKER -static int (*mec_post_event)(char *data, unsigned long len) = NULL; +typedef int (*mec_post_event_pointer)(char *data, unsigned long len); +static mec_post_event_pointer mec_post_event = NULL; #endif static unsigned copy_into_cyclic_buffer (char *buffer, unsigned dst_offset, char *src, unsigned size) @@ -1354,7 +1355,7 @@ int put_us_event (char *data, unsigned long len) else { // FIXME: 'mec_post_event' - not found - mec_post_event = swap_ksyms("mec_post_event"); + mec_post_event = (mec_post_event_pointer) swap_ksyms("mec_post_event"); if(mec_post_event == NULL) { EPRINTF ("Failed to find function 'mec_post_event' from mec_handlers.ko. Memory Error Checker will work incorrectly."); diff --git a/driver/us_proc_inst.c b/driver/us_proc_inst.c index 4ff1b1ad..b0ae91e7 100644 --- a/driver/us_proc_inst.c +++ b/driver/us_proc_inst.c @@ -47,9 +47,6 @@ mmput(mm); \ } -DEFINE_PER_CPU (us_proc_vtp_t *, gpVtp) = NULL; -DEFINE_PER_CPU (struct pt_regs *, gpCurVtpRegs) = NULL; - #if defined(CONFIG_MIPS) # define ARCH_REG_VAL(regs, idx) regs->regs[idx] #elif defined(CONFIG_ARM) @@ -63,17 +60,11 @@ unsigned long ujprobe_event_pre_handler (struct us_ip *ip, struct pt_regs *regs) void ujprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6); int uretprobe_event_handler (struct kretprobe_instance *probe, struct pt_regs *regs, struct us_ip *ip); -static int register_usprobe(struct task_struct *task, struct us_ip *ip, int atomic); -static int unregister_usprobe(struct task_struct *task, struct us_ip *ip, int atomic, int no_rp2); int us_proc_probes; LIST_HEAD(proc_probes_list); -#ifdef SLP_APP -struct dentry *launchpad_daemon_dentry = NULL; -EXPORT_SYMBOL_GPL(launchpad_daemon_dentry); -#endif /* SLP_APP */ #ifdef ANDROID_APP unsigned long android_app_vma_start = 0; @@ -81,6 +72,10 @@ unsigned long android_app_vma_end = 0; struct dentry *app_process_dentry = NULL; #endif /* ANDROID_APP */ +#ifdef SLP_APP +static struct dentry *launchpad_daemon_dentry = NULL; +EXPORT_SYMBOL_GPL(launchpad_daemon_dentry); +#endif /* SLP_APP */ #define print_event(fmt, args...) \ { \ @@ -629,8 +624,6 @@ int inst_usr_space_proc (void) #include "../../tools/gpmu/probes/entry_data.h" -extern storage_arg_t sa_dpf; - void do_page_fault_j_pre_code(unsigned long addr, unsigned int fsr, struct pt_regs *regs) { struct task_struct *task = current->group_leader; @@ -649,8 +642,6 @@ EXPORT_SYMBOL_GPL(do_page_fault_j_pre_code); unsigned long imi_sum_time = 0; unsigned long imi_sum_hit = 0; -EXPORT_SYMBOL_GPL (imi_sum_time); -EXPORT_SYMBOL_GPL (imi_sum_hit); static void set_mapping_file(struct sspt_file *file, const struct sspt_procs *procs, @@ -1124,13 +1115,11 @@ void copy_process_ret_pre_code(struct task_struct *p) rm_uprobes_child(p); } - -DEFINE_PER_CPU(struct us_ip *, gpCurIp) = NULL; +static DEFINE_PER_CPU(struct us_ip *, gpCurIp) = NULL; EXPORT_PER_CPU_SYMBOL_GPL(gpCurIp); -DEFINE_PER_CPU(struct pt_regs *, gpUserRegs) = NULL; +static DEFINE_PER_CPU(struct pt_regs *, gpUserRegs) = NULL; EXPORT_PER_CPU_SYMBOL_GPL(gpUserRegs); - unsigned long ujprobe_event_pre_handler(struct us_ip *ip, struct pt_regs *regs) { __get_cpu_var (gpCurIp) = ip; @@ -1224,7 +1213,7 @@ int uretprobe_event_handler(struct kretprobe_instance *probe, struct pt_regs *re return 0; } -static int register_usprobe(struct task_struct *task, struct us_ip *ip, int atomic) +int register_usprobe(struct task_struct *task, struct us_ip *ip, int atomic) { int ret = 0; ip->jprobe.kp.tgid = task->tgid; @@ -1265,7 +1254,7 @@ static int register_usprobe(struct task_struct *task, struct us_ip *ip, int atom return 0; } -static int unregister_usprobe(struct task_struct *task, struct us_ip *ip, int atomic, int not_rp2) +int unregister_usprobe(struct task_struct *task, struct us_ip *ip, int atomic, int not_rp2) { dbi_unregister_ujprobe(task, &ip->jprobe, atomic); diff --git a/driver/us_proc_inst.h b/driver/us_proc_inst.h index 66ed2524..059ee99c 100644 --- a/driver/us_proc_inst.h +++ b/driver/us_proc_inst.h @@ -80,6 +80,14 @@ extern int dump_backtrace(probe_id_t probe_id, struct task_struct *task, /* Gets current function return address */ extern unsigned long get_ret_addr(struct task_struct *task, struct us_ip *ip); +extern unsigned long imi_sum_time; +extern unsigned long imi_sum_hit; + +extern struct list_head proc_probes_list; + +int register_usprobe(struct task_struct *task, struct us_ip *ip, int atomic); +int unregister_usprobe(struct task_struct *task, struct us_ip *ip, int atomic, int no_rp2); + #define user_backtrace(size) \ do { \ us_proc_ip_t *ip = __get_cpu_var(gpCurIp); \ @@ -87,4 +95,10 @@ extern unsigned long get_ret_addr(struct task_struct *task, struct us_ip *ip); dump_backtrace(US_PROBE_ID, current, ip->jprobe.kp.addr, regs, size); \ } while (0) +struct dentry *dentry_by_path(const char *path); +int install_otg_ip(unsigned long addr, + kprobe_pre_entry_handler_t pre_handler, + unsigned long jp_handler, + kretprobe_handler_t rp_handler); + #endif /* !defined(__US_PROC_INST_H__) */ |