From 5752a5a280a11c1f35228a6bab2d2d9a3a60ad7a Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Tue, 9 Apr 2013 12:53:48 +0400 Subject: [PATCH] [CLEAN] remove java instrumentation --- driver/Kbuild | 2 +- driver/Makefile.am | 9 +--- driver/java_inst.c | 143 -------------------------------------------------- driver/java_inst.h | 45 ---------------- driver/sspt/sspt.h | 3 -- driver/us_proc_inst.c | 13 ----- kprobe/Makefile.am | 5 -- 7 files changed, 2 insertions(+), 218 deletions(-) delete mode 100644 driver/java_inst.c delete mode 100644 driver/java_inst.h diff --git a/driver/Kbuild b/driver/Kbuild index b50621d..54d39d4 100644 --- a/driver/Kbuild +++ b/driver/Kbuild @@ -2,5 +2,5 @@ EXTRA_CFLAGS := $(extra_cflags) 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 java_inst.o \ + probes_manager.o storage.o us_proc_inst.o \ sspt/ip.o sspt/sspt_page.o sspt/sspt_file.o sspt/sspt_procs.o diff --git a/driver/Makefile.am b/driver/Makefile.am index 5ddc464..f8d1750 100644 --- a/driver/Makefile.am +++ b/driver/Makefile.am @@ -10,12 +10,7 @@ if SPARSE sparse_output = C=2 endif -if ANDROID -android_opt = -D__ANDROID -android = yes -else dev_path = @TARGET_DEVICE_PATH@ -endif board_opt = -DBOARD_@BOARD@ @@ -52,10 +47,8 @@ install-exec-local: install -m 755 $(driver_module_dir)/patchko.sh $(prefix)/bin install -m 755 $(driver_module_dir)/insmod.sh $(prefix)/bin - if [ "$(android)" != "yes" ] ; then \ sed "s|__DEV_NAME__|`basename $(dev_path)`|" $(driver_module_dir)/$(module_name).sh | \ sed "s|__DEV_DIR__|`dirname $(dev_path)`|" > \ $(prefix)/$(module_name).sh ; chmod +x $(prefix)/$(module_name).sh ; \ chmod +x $(driver_module_dir)/patchko.sh ; \ - chmod +x $(driver_module_dir)/insmod.sh ; \ - fi + chmod +x $(driver_module_dir)/insmod.sh ; diff --git a/driver/java_inst.c b/driver/java_inst.c deleted file mode 100644 index f5cd98d..0000000 --- a/driver/java_inst.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Dynamic Binary Instrumentation Module based on KProbes - * modules/driver/sspt/java_inst.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright (C) Samsung Electronics, 2013 - * - * 2012 Nikita Kalyazin java implementation - * 2013 Vyacheslav Cherkashin redesign module - * - */ - -#include "java_inst.h" - -#ifdef __ANDROID - -#include -#include -#include -#include "ec_probe.h" -#include "picl.h" -#include "storage.h" -#include "debug.h" -#include "sspt/ip.h" -#include "sspt/sspt_procs.h" - - -/* Defines below are for libdvm.so with md5sum: - * 5941c87b49198368e7db726c2977bf1d */ -enum { - LIBDVM_ENTRY = 0x30a64, - LIBDVM_RETURN = 0x30bdc -}; - -struct dentry *libdvm_dentry = NULL; - -struct dentry *dentry_by_path(const char *path); - -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); - -void add_java_inst(struct sspt_procs *procs) -{ - struct dentry *dentry = dentry_by_path("/system/lib/libdvm.so"); - libdvm_dentry = dentry; - const char *name = "libdvm.so"; - - struct ip_data ipd_entry = { - .offset = LIBDVM_ENTRY, - .got_addr = 0, - .pre_handler = ujprobe_event_pre_handler, - .jp_handler = ujprobe_event_handler, - .rp_handler = 0, - .flag_retprobe = 0 - }; - - sspt_procs_add_ip_data(procs, dentry, name, &ipd_entry); - - - struct ip_data ipd_return = { - .offset = LIBDVM_RETURN, - .got_addr = 0, - .pre_handler = ujprobe_event_pre_handler, - .jp_handler = ujprobe_event_handler, - .rp_handler = 0, - .flag_retprobe = 0 - }; - - sspt_procs_add_ip_data(procs, dentry, name, &ipd_return); -} - -extern void dbi_uprobe_return(void); - -static inline int pre_handle_java_event(unsigned long start, unsigned long addr, struct pt_regs *regs) -{ - if (addr == start + LIBDVM_ENTRY) { - unsigned long *p_met = (unsigned long *)regs->ARM_r0; - char *met_name = p_met ? (char *)(p_met[4]) : 0; - unsigned long *p_cl = p_met ? (unsigned long *)p_met[0] : 0; - char *cl_name = p_cl ? (char *)(p_cl[6]) : 0; - - if (!cl_name || !met_name) { - EPRINTF("warn: class name or method name null\n"); - } else { - pack_event_info(JAVA_PROBE_ID, RECORD_ENTRY, "pss", addr, cl_name, met_name); - } - - dbi_uprobe_return (); - - return 1; - } else if (addr == start + LIBDVM_RETURN) { - unsigned long *p_th = (unsigned long *)regs->ARM_r6; - unsigned long *p_st = p_th; - unsigned long *p_met = p_st ? (unsigned long *)p_st[2] : 0; - char *met_name = p_met ? (char *)(p_met[4]) : 0; - unsigned long *p_cl = p_met ? (unsigned long *)p_met[0] : 0; - char *cl_name = p_cl ? (char *)(p_cl[6]) : 0; - - if (!cl_name || !met_name) { - EPRINTF("warn: class name or method name null\n"); - } else { - pack_event_info(JAVA_PROBE_ID, RECORD_RET, "pss", addr, cl_name, met_name); - } - - dbi_uprobe_return (); - - return 1; - } - - return 0; -} - -int handle_java_event(struct pt_regs *regs) -{ - struct mm_struct *mm = current->mm; - unsigned long addr = regs->ARM_pc; - - if (mm && libdvm_dentry) { - struct vm_area_struct *vma = find_vma(mm, addr); - if (vma && (vma->vm_flags & VM_EXEC) && - vma->vm_file && vma->vm_file->f_dentry && - (vma->vm_file->f_dentry == libdvm_dentry)) { - return pre_handle_java_event(vma->vm_start, addr, regs); - } - } - - return 0; -} - -#endif /* __ANDROID */ diff --git a/driver/java_inst.h b/driver/java_inst.h deleted file mode 100644 index 5eec385..0000000 --- a/driver/java_inst.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __JAVA_INST__ -#define __JAVA_INST__ - -/* - * Dynamic Binary Instrumentation Module based on KProbes - * modules/driver/java_inst.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright (C) Samsung Electronics, 2013 - * - * 2013 Vyacheslav Cherkashin - * - */ - -struct pt_regs; -struct sspt_procs; - -#ifdef __ANDROID -void add_java_inst(struct sspt_procs *procs); -int handle_java_event(struct pt_regs *regs); -#else /* __ANDROID */ -static inline void add_java_inst(struct sspt_procs *procs) -{ -} - -static inline int handle_java_event(struct pt_regs *regs) -{ - return 0; -} -#endif /* __ANDROID */ - -#endif /* __JAVA_INST__ */ diff --git a/driver/sspt/sspt.h b/driver/sspt/sspt.h index ef72ad5..a254816 100644 --- a/driver/sspt/sspt.h +++ b/driver/sspt/sspt.h @@ -35,7 +35,6 @@ #include "../storage.h" -#include "../java_inst.h" static void print_proc_probes(const struct sspt_procs *procs); @@ -82,8 +81,6 @@ static inline struct sspt_procs *get_file_probes(const inst_us_proc_t *task_inst } } - add_java_inst(procs); - // print_proc_probes(procs); printk("####### get END #######\n"); diff --git a/driver/us_proc_inst.c b/driver/us_proc_inst.c index bdb3469..751431b 100644 --- a/driver/us_proc_inst.c +++ b/driver/us_proc_inst.c @@ -22,7 +22,6 @@ #include "../uprobe/swap_uprobes.h" #include "sspt/sspt.h" -#include "java_inst.h" #include @@ -234,13 +233,9 @@ struct dentry *dentry_by_path(const char *path) static int check_vma(struct vm_area_struct *vma) { -#ifndef __ANDROID return vma->vm_file && !(vma->vm_pgoff != 0 || !(vma->vm_flags & VM_EXEC) || (vma->vm_flags & VM_ACCOUNT) || !(vma->vm_flags & (VM_WRITE | VM_MAYWRITE)) || !(vma->vm_flags & (VM_READ | VM_MAYREAD))); -#else // __ANDROID - return vma->vm_file && !(vma->vm_pgoff != 0 || !(vma->vm_flags & VM_EXEC)); -#endif // __ANDROID } static int find_task_by_path (const char *path, struct task_struct **p_task, struct list_head *tids) @@ -1114,14 +1109,6 @@ void ujprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned lon struct us_ip *ip = __get_cpu_var(gpCurIp); unsigned long addr = (unsigned long)ip->jprobe.up.kp.addr; -#ifdef __ANDROID - struct pt_regs *regs = __get_cpu_var(gpUserRegs); - if (is_java_inst_enabled() && handle_java_event(regs)) { - return; - } -#endif /* __ANDROID */ - - #if defined(CONFIG_ARM) if (ip->offset & 0x01) { diff --git a/kprobe/Makefile.am b/kprobe/Makefile.am index 36536e9..5a1814a 100644 --- a/kprobe/Makefile.am +++ b/kprobe/Makefile.am @@ -1,8 +1,3 @@ -if ANDROID -android_opt = -D__ANDROID -android = yes -endif - if SPARSE sparse_output = C=2 endif -- 2.7.4