From: Nikita Kalyazin Date: Tue, 3 Jul 2012 16:12:21 +0000 (+0400) Subject: Fix of browser instrumentation problem (#363) X-Git-Tag: Tizen_SDK_2.3~791 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a3af07a302b64b720794f9a7294bd7ceb2b83777;p=kernel%2Fswap-modules.git Fix of browser instrumentation problem (#363) The fix is raw and needs for some cleanup. - Added do_fork handler (separate from do_exit's one); - Added arch_disarm_uprobe() call when deferred uprobe unregistering (this matters when a process forks while another one is inside the insrumented function). TODO: - Consider all the auxiliary handlers (do_exec, do_exit, do_fork); - Consider deferred probes management (disarming). --- diff --git a/driver/probes_manager.c b/driver/probes_manager.c index 498f4bf..cf614cb 100644 --- a/driver/probes_manager.c +++ b/driver/probes_manager.c @@ -406,7 +406,7 @@ def_jprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned long * TODO: call fork specific * *_probe_pre_code() function */ - do_exit_probe_pre_code(); + do_fork_probe_pre_code(); } if (!(probes_flags & PROBE_FLAG_FORK_INSTLD)) skip = 1; diff --git a/driver/us_proc_inst.c b/driver/us_proc_inst.c index a081708..28a6dd5 100644 --- a/driver/us_proc_inst.c +++ b/driver/us_proc_inst.c @@ -1485,6 +1485,39 @@ void do_exit_probe_pre_code (void) } EXPORT_SYMBOL_GPL(do_exit_probe_pre_code); +void do_fork_probe_pre_code(void) +{ + int ret = 0; + struct task_struct *task; + inst_us_proc_t *task_inst_info = NULL; + + /* if user-space instrumentation is not set */ + if (!us_proc_info.path) { + return; + } + + if (!strcmp(us_proc_info.path,"*")) { + task_inst_info = get_task_inst_node(current); + if (task_inst_info) { + ret = uninstall_mapped_ips (current, task_inst_info, 1); + if (ret != 0) { + EPRINTF("failed to uninstall IPs (%d)!", ret); + } + dbi_unregister_all_uprobes(current, 1); + } + return; + } else { + if (current->tgid != us_proc_info.tgid) { + return; + } + ret = uninstall_mapped_ips(current->group_leader, &us_proc_info, 1); + if (ret != 0) { + EPRINTF("failed to uninstall IPs (%d)!", ret); + } + us_proc_info.tgid = 0; + } +} + DEFINE_PER_CPU (us_proc_ip_t *, gpCurIp) = NULL; EXPORT_PER_CPU_SYMBOL_GPL(gpCurIp); DEFINE_PER_CPU(struct pt_regs *, gpUserRegs) = NULL; diff --git a/driver/us_proc_inst.h b/driver/us_proc_inst.h index 5a5e595..a9c1dd1 100644 --- a/driver/us_proc_inst.h +++ b/driver/us_proc_inst.h @@ -39,6 +39,8 @@ extern void do_page_fault_ret_pre_code (void); */ extern void do_exit_probe_pre_code (void); +extern void do_fork_probe_pre_code (void); + /* Detects when target process is killed and removes IPs. */ diff --git a/kprobe/dbi_uprobes.c b/kprobe/dbi_uprobes.c index 536921d..1007c71 100644 --- a/kprobe/dbi_uprobes.c +++ b/kprobe/dbi_uprobes.c @@ -269,6 +269,7 @@ void dbi_unregister_uretprobe (struct task_struct *task, struct kretprobe *rp, i { DBPRINTF ("initiating deferred retprobe deletion addr %p", rp->kp.addr); printk ("initiating deferred retprobe deletion addr %p\n", rp->kp.addr); + arch_disarm_uprobe(&rp->kp, task); rp2->disarm = 1; } /*