if (iRet)
EPRINTF ("uninstall_kernel_probe(do_exit) result=%d!", iRet);
- if (!strcmp(us_proc_info.path,"*"))
+ 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())
{
for_each_process (task)
{
}
EXPORT_SYMBOL_GPL(do_exit_probe_pre_code);
- err = unregister_usprobe(task, &task_inst_info->p_libs[i].p_ips[k], atomic);
+ static int check_addr(unsigned long addr, unsigned long start, size_t len)
+ {
+ if ((addr >= start) && (addr < start + (unsigned long)len)) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ static int remove_unmap_probes(struct task_struct *task, inst_us_proc_t* task_inst_info, unsigned long start, size_t len)
+ {
+ int i, k, err;
+ us_proc_otg_ip_t *p;
+ unsigned long addr;
+ const int atomic = 1;
+
+ for (i = 0; i < task_inst_info->libs_count; ++i) {
+ for (k = 0; k < task_inst_info->p_libs[i].ips_count; ++k) {
+ if (task_inst_info->p_libs[i].p_ips[k].installed) {
+ addr = task_inst_info->p_libs[i].p_ips[k].jprobe.kp.addr;
+ if (check_addr(addr, start, len)) {
- unregister_usprobe(task, entp, atomic);
++ err = unregister_usprobe(task, &task_inst_info->p_libs[i].p_ips[k], atomic, 1);
+ if (err != 0) {
+ EPRINTF("failed to uninstall IP at %p. Error %d!", task_inst_info->p_libs[i].p_ips[k].jprobe.kp.addr, err);
+ continue;
+ }
+ task_inst_info->unres_ips_count++;
+ task_inst_info->p_libs[i].p_ips[k].installed = 0;
+ }
+ }
+ }
+ for (k = 0; k < task_inst_info->p_libs[i].vtps_count; ++k) {
+ if (task_inst_info->p_libs[i].p_vtps[k].installed) {
+ addr = task_inst_info->p_libs[i].p_vtps[k].jprobe.kp.addr;
+ if (check_addr(addr, start, len)) {
+ dbi_unregister_ujprobe(task, &task_inst_info->p_libs[i].p_vtps[k].jprobe, atomic);
+ task_inst_info->unres_vtps_count++;
+ task_inst_info->p_libs[i].p_vtps[k].installed = 0;
+ }
+ }
+ }
+ }
+ #ifdef __ANDROID
+ if (is_java_inst_enabled()) {
+ us_proc_ip_t *entp = &task_inst_info->libdvm_entry_ip;
+ if (entp->installed) {
+ addr = entp->jprobe.kp.addr;
+ if (check_addr(addr, start, len)) {
- unregister_usprobe(task, retp, atomic);
++ unregister_usprobe(task, entp, atomic, 1);
+ entp->installed = 0;
+ }
+ }
+ us_proc_ip_t *retp = &task_inst_info->libdvm_return_ip;
+ if (retp->installed) {
+ addr = retp->jprobe.kp.addr;
+ if (check_addr(addr, start, len)) {
- err = unregister_usprobe(task, &p->ip, atomic);
++ unregister_usprobe(task, retp, atomic, 1);
+ retp->installed = 0;
+ }
+ }
+ }
+ #endif /* __ANDROID */
+ list_for_each_entry_rcu (p, &otg_us_proc_info, list) {
+ if (!p->ip.installed) {
+ continue;
+ }
+
+ addr = p->ip.jprobe.kp.addr;
+ if (check_addr(addr, start, len) == 0) {
+ continue;
+ }
+
++ err = unregister_usprobe(task, &p->ip, atomic, 1);
+ if (err != 0) {
+ EPRINTF("failed to uninstall IP at %p. Error %d!",
+ p->ip.jprobe.kp.addr, err);
+ continue;
+ }
+ p->ip.installed = 0;
+ }
+
+ return 0;
+ }
+
+ void do_munmap_probe_pre_code(struct mm_struct *mm, unsigned long start, size_t len)
+ {
+ inst_us_proc_t *task_inst_info = NULL;
+ struct task_struct *task = current;
+
+ //if user-space instrumentation is not set
+ if (!us_proc_info.path || task->tgid != task->pid)
+ return;
+
+ if (!strcmp(us_proc_info.path,"*")) {
+ task_inst_info = get_task_inst_node(task);
+ } else {
+ if (task->tgid == us_proc_info.tgid) {
+ task_inst_info = &us_proc_info;
+ }
+ }
+
+ if (task_inst_info) {
+ remove_unmap_probes(task, task_inst_info, start, len);
+ }
+ }
+ EXPORT_SYMBOL_GPL(do_munmap_probe_pre_code);
+
void mm_release_probe_pre_code(void)
{
- int iRet, del = 0;
+ int iRet;
struct task_struct *task;
- inst_us_proc_t *task_inst_info = NULL;
- //if user-space instrumentation is not set
- if (!us_proc_info.path || current->tgid != current->pid)
+ if (!is_us_instrumentation() || current->tgid != current->pid) {
return;
+ }
- if (!strcmp(us_proc_info.path,"*"))
- {
- task_inst_info = get_task_inst_node(current);
- if (task_inst_info)
- {
- iRet = uninstall_mapped_ips (current, task_inst_info, 1);
- if (iRet != 0)
+ if (is_libonly()) {
+ inst_us_proc_t *task_inst_info = get_task_inst_node(current);
+ if (task_inst_info) {
+ iRet = uninstall_us_proc_probes(current, task_inst_info->pp, US_NOT_RP2);
+ if (iRet != 0) {
EPRINTF ("failed to uninstall IPs (%d)!", iRet);
- dbi_unregister_all_uprobes(current, 1);
- }
- }
- else
- {
- if (current->tgid != us_proc_info.tgid)
- return;
- del = 1;
- // look for another process with the same tgid
- rcu_read_lock ();
- for_each_process (task)
- {
- if ((task->pid != current->pid) && (task->tgid == us_proc_info.tgid))
- {
- del = 0;
- break;
}
+
+ dbi_unregister_all_uprobes(current, 1);
}
- rcu_read_unlock ();
- if (del)
- {
+ } else {
+ if (current->tgid == us_proc_info.tgid && current->tgid == current->pid) {
int i;
- iRet = uninstall_mapped_ips (current, &us_proc_info, 1);
- if (iRet != 0)
+ iRet = uninstall_us_proc_probes(current, us_proc_info.pp, US_NOT_RP2);
+ if (iRet != 0) {
EPRINTF ("failed to uninstall IPs (%d)!", iRet);
+ }
+
dbi_unregister_all_uprobes(current, 1);
us_proc_info.tgid = 0;
- for(i = 0; i < us_proc_info.libs_count; i++)
+ for(i = 0; i < us_proc_info.libs_count; i++) {
us_proc_info.p_libs[i].loaded = 0;
+ }
}
}
}