summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
Diffstat (limited to 'driver')
-rw-r--r--driver/storage.c17
-rw-r--r--driver/us_proc_inst.c168
2 files changed, 97 insertions, 88 deletions
diff --git a/driver/storage.c b/driver/storage.c
index c7d82a82..59e9c263 100644
--- a/driver/storage.c
+++ b/driver/storage.c
@@ -602,11 +602,9 @@ void unlink_bundle(void)
kfree ((void *) us_proc_info.p_libs);
us_proc_info.p_libs = NULL;
}
- /* if (path) */
- /* { */
- /* kfree ((void *) path); */
- /* //putname(path); */
- /* } */
+ if (path) {
+ kfree ((void *) path);
+ }
us_proc_info.tgid = 0;
}
@@ -692,9 +690,14 @@ int link_bundle(void)
{
int lib_path_len;
char *lib_path;
-
- us_proc_info.path = (char *)p;
+ us_proc_info.path = kmalloc(len, GFP_KERNEL);
+ if (!us_proc_info.path) {
+ DPRINTF("Can't allocate memory for us_proc_info.path");
+ return -1;
+ }
+ us_proc_info.path = strcpy(us_proc_info.path, (char *)p);
DPRINTF("app path = %s", us_proc_info.path);
+ printk("app path = %s\n", us_proc_info.path);
p += len;
if (strcmp(us_proc_info.path, "*")) {
diff --git a/driver/us_proc_inst.c b/driver/us_proc_inst.c
index 77642eaf..db564c05 100644
--- a/driver/us_proc_inst.c
+++ b/driver/us_proc_inst.c
@@ -411,26 +411,6 @@ int deinst_usr_space_proc (void)
if (iRet)
EPRINTF ("uninstall_kernel_probe(do_page_fault) result=%d!", iRet);
- iRet = uninstall_kernel_probe (cp_addr, US_PROC_CP_INSTLD,
- 0, &cp_probe);
- if (iRet)
- EPRINTF ("uninstall_kernel_probe(copy_process) result=%d!", iRet);
-
- iRet = uninstall_kernel_probe (mr_addr, US_PROC_MR_INSTLD,
- 0, &mr_probe);
- if (iRet)
- EPRINTF ("uninstall_kernel_probe(mm_release) result=%d!", iRet);
-
- iRet = uninstall_kernel_probe (exit_addr, US_PROC_EXIT_INSTLD,
- 0, &exit_probe);
- if (iRet)
- EPRINTF ("uninstall_kernel_probe(do_exit) result=%d!", iRet);
-
- iRet = uninstall_kernel_probe (unmap_addr, US_PROC_UNMAP_INSTLD,
- 0, &unmap_probe);
- if (iRet)
- EPRINTF ("uninstall_kernel_probe(do_munmap) result=%d!", iRet);
-
if (is_libonly()) {
struct sspt_proc *proc;
@@ -448,38 +428,61 @@ int deinst_usr_space_proc (void)
}
else
{
- if (us_proc_info.tgid == 0)
- return 0;
+ if (us_proc_info.tgid != 0) {
rcu_read_lock ();
- for_each_process (task)
- {
- if (task->tgid == us_proc_info.tgid)
+ for_each_process (task)
{
- found = 1;
- get_task_struct (task);
- break;
- }
- }
- rcu_read_unlock ();
- if (found)
- {
- int i, ret;
- // uninstall IPs
- ret = uninstall_us_proc_probes(task, us_proc_info.pp, US_UNREGS_PROBE);
- if (ret != 0) {
- EPRINTF ("failed to uninstall IPs %d!", ret);
+ if (task->tgid == us_proc_info.tgid)
+ {
+ found = 1;
+ get_task_struct (task);
+ break;
+ }
}
+ rcu_read_unlock ();
+ if (found)
+ {
+ int i, ret;
+ // uninstall IPs
+ ret = uninstall_us_proc_probes(task,
+ us_proc_info.pp,
+ US_UNREGS_PROBE);
+ if (ret != 0) {
+ EPRINTF ("failed to uninstall IPs %d!",
+ ret);
+ }
- put_task_struct (task);
+ put_task_struct (task);
- printk("### 1 ### dbi_unregister_all_uprobes:\n");
- dbi_unregister_all_uprobes(task, 1);
- us_proc_info.tgid = 0;
- for(i = 0; i < us_proc_info.libs_count; i++)
- us_proc_info.p_libs[i].loaded = 0;
+ printk("###1### dbi_unregister_all_uprobes:\n");
+ dbi_unregister_all_uprobes(task, 1);
+ us_proc_info.tgid = 0;
+ for(i = 0; i < us_proc_info.libs_count; i++)
+ us_proc_info.p_libs[i].loaded = 0;
+ }
}
}
+ iRet = uninstall_kernel_probe (cp_addr, US_PROC_CP_INSTLD,
+ 0, &cp_probe);
+ if (iRet)
+ EPRINTF ("uninstall_kernel_probe(copy_process) result=%d!", iRet);
+
+ iRet = uninstall_kernel_probe (mr_addr, US_PROC_MR_INSTLD,
+ 0, &mr_probe);
+ if (iRet)
+ EPRINTF ("uninstall_kernel_probe(mm_release) result=%d!", iRet);
+
+ iRet = uninstall_kernel_probe (exit_addr, US_PROC_EXIT_INSTLD,
+ 0, &exit_probe);
+ if (iRet)
+ EPRINTF ("uninstall_kernel_probe(do_exit) result=%d!", iRet);
+
+ iRet = uninstall_kernel_probe (unmap_addr, US_PROC_UNMAP_INSTLD,
+ 0, &unmap_probe);
+ if (iRet)
+ EPRINTF ("uninstall_kernel_probe(do_munmap) result=%d!", iRet);
+
return iRet;
}
static int install_kernel_probe (unsigned long addr, int uflag, int kflag, kernel_probe_t ** pprobe)
@@ -529,6 +532,46 @@ int inst_usr_space_proc (void)
DPRINTF("User space instr");
+ // enable 'do_exit' probe to detect for remove task_struct
+ ret = install_kernel_probe (exit_addr, US_PROC_EXIT_INSTLD, 0, &exit_probe);
+ if (ret != 0)
+ {
+ EPRINTF ("install_kernel_probe(do_exit) result=%d!", ret);
+ return ret;
+ }
+
+ // enable 'mm_release' probe to detect when for remove user space probes
+ ret = install_kernel_probe (mr_addr, US_PROC_MR_INSTLD, 0, &mr_probe);
+ if (ret != 0)
+ {
+ EPRINTF ("install_kernel_probe(mm_release) result=%d!", ret);
+ return ret;
+ }
+
+ // enable 'do_munmap' probe to detect when for remove user space probes
+ ret = install_kernel_probe (unmap_addr, US_PROC_UNMAP_INSTLD, 0, &unmap_probe);
+ if (ret != 0)
+ {
+ EPRINTF ("install_kernel_probe(do_munmap) result=%d!", ret);
+ return ret;
+ }
+
+ /* enable 'copy_process' */
+ ret = install_kernel_probe (cp_addr, US_PROC_CP_INSTLD, 0, &cp_probe);
+ if (ret != 0)
+ {
+ EPRINTF ("instpall_kernel_probe(copy_process) result=%d!", ret);
+ return ret;
+ }
+
+ // enable 'do_page_fault' probe to detect when they will be loaded
+ ret = install_kernel_probe (pf_addr, US_PROC_PF_INSTLD, 0, &pf_probe);
+ if (ret != 0)
+ {
+ EPRINTF ("install_kernel_probe(do_page_fault) result=%d!", ret);
+ return ret;
+ }
+
#ifdef SLP_APP
launchpad_daemon_dentry = dentry_by_path("/usr/bin/launchpad_preloading_preinitializing_daemon");
if (launchpad_daemon_dentry == NULL) {
@@ -588,43 +631,6 @@ int inst_usr_space_proc (void)
}
}
- // enable 'do_page_fault' probe to detect when they will be loaded
- ret = install_kernel_probe (pf_addr, US_PROC_PF_INSTLD, 0, &pf_probe);
- if (ret != 0)
- {
- EPRINTF ("install_kernel_probe(do_page_fault) result=%d!", ret);
- return ret;
- }
- // enable 'do_exit' probe to detect for remove task_struct
- ret = install_kernel_probe (exit_addr, US_PROC_EXIT_INSTLD, 0, &exit_probe);
- if (ret != 0)
- {
- EPRINTF ("install_kernel_probe(do_exit) result=%d!", ret);
- return ret;
- }
- /* enable 'copy_process' */
- ret = install_kernel_probe (cp_addr, US_PROC_CP_INSTLD, 0, &cp_probe);
- if (ret != 0)
- {
- EPRINTF ("instpall_kernel_probe(copy_process) result=%d!", ret);
- return ret;
- }
-
- // enable 'mm_release' probe to detect when for remove user space probes
- ret = install_kernel_probe (mr_addr, US_PROC_MR_INSTLD, 0, &mr_probe);
- if (ret != 0)
- {
- EPRINTF ("install_kernel_probe(mm_release) result=%d!", ret);
- return ret;
- }
-
- // enable 'do_munmap' probe to detect when for remove user space probes
- ret = install_kernel_probe (unmap_addr, US_PROC_UNMAP_INSTLD, 0, &unmap_probe);
- if (ret != 0)
- {
- EPRINTF ("install_kernel_probe(do_munmap) result=%d!", ret);
- return ret;
- }
return 0;
}