Fix of browser instrumentation problem (#363)
authorNikita Kalyazin <n.kalyazin@samsung.com>
Tue, 3 Jul 2012 16:12:21 +0000 (20:12 +0400)
committerNikita Kalyazin <n.kalyazin@samsung.com>
Tue, 3 Jul 2012 16:16:44 +0000 (20:16 +0400)
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).

driver/probes_manager.c
driver/us_proc_inst.c
driver/us_proc_inst.h
kprobe/dbi_uprobes.c

index 498f4bf..cf614cb 100644 (file)
@@ -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;
index a081708..28a6dd5 100644 (file)
@@ -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;
index 5a5e595..a9c1dd1 100644 (file)
@@ -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.
 */
index 536921d..1007c71 100644 (file)
@@ -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;
                }
                /*