From: Frank Ch. Eigler Date: Fri, 22 Aug 2008 16:10:17 +0000 (-0400) Subject: pr4225: fix shared library address range checks; make more task_finder_vma tracing... X-Git-Tag: release-0.7.2~34^2~13 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=c16d425a5dd60fd86efb76a429b65f87dfb5e44a;p=systemtap.git pr4225: fix shared library address range checks; make more task_finder_vma tracing conditional on DEBUG_TASK_FINDER_VMA --- diff --git a/runtime/task_finder_vma.c b/runtime/task_finder_vma.c index 9d43e36c5..c06b3db0f 100644 --- a/runtime/task_finder_vma.c +++ b/runtime/task_finder_vma.c @@ -133,11 +133,13 @@ __stp_tf_add_vma(struct task_struct *tsk, unsigned long addr, hlist_for_each_entry(entry, node, head, hlist) { if (tsk->pid == entry->pid && addr == entry->addr) { - printk(KERN_NOTICE - "vma (pid: %d, vm_start: 0x%lx) present?\n", - tsk->pid, vma->vm_start); - mutex_unlock(&__stp_tf_vma_mutex); - return -EBUSY; /* Already there */ +#if DEBUG_TASK_FINDER_VMA + printk(KERN_NOTICE + "vma (pid: %d, vm_start: 0x%lx) present?\n", + tsk->pid, vma->vm_start); +#endif + mutex_unlock(&__stp_tf_vma_mutex); + return -EBUSY; /* Already there */ } } diff --git a/tapsets.cxx b/tapsets.cxx index 409d909a8..7755d7942 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -6881,14 +6881,18 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline(); s.op->newline() << "static int stap_uprobe_vmchange_found (struct stap_task_finder_target *tgt, struct task_struct *tsk, int map_p, char *vm_path, unsigned long vm_start, unsigned long vm_end, unsigned long vm_pgoff) {"; s.op->newline(1) << "struct stap_uprobe_spec *sups = container_of(tgt, struct stap_uprobe_spec, finder);"; - s.op->newline() << "printk (KERN_INFO \"vmchange pid %d map_p %d path %s vms %p vme %p vmp %p\\n\", tsk->tgid, map_p, vm_path, (void*) vm_start, (void*) vm_end, (void*) vm_pgoff);"; - s.op->newline() << "printk (KERN_INFO \"sups %p pp %s path %s address %p\\n\", sups, sups->pp, sups->pathname ?: \"\", (void*) sups->address);"; // 1 - shared libraries' executable segments load from offset 0 - ld.so convention s.op->newline() << "if (vm_pgoff != 0) return 0;"; // 2 - the shared library we're interested in s.op->newline() << "if (vm_path == NULL || strcmp (vm_path, sups->pathname)) return 0;"; // 3 - probe address within the mapping limits; test should not fail - s.op->newline() << "if (vm_end >= sups->address) return 0;"; + s.op->newline() << "if (vm_end <= vm_start + sups->address) return 0;"; + + s.op->newline() << "#ifdef DEBUG_TASK_FINDER_VMA"; + s.op->newline() << "printk (KERN_INFO \"vmchange pid %d map_p %d path %s vms %p vme %p vmp %p\\n\", tsk->tgid, map_p, vm_path, (void*) vm_start, (void*) vm_end, (void*) vm_pgoff);"; + s.op->newline() << "printk (KERN_INFO \"sups %p pp %s path %s address %p\\n\", sups, sups->pp, sups->pathname ?: \"\", (void*) sups->address);"; + s.op->newline() << "#endif"; + s.op->newline(0) << "return stap_uprobe_change (tsk, map_p, vm_start, sups);"; s.op->newline(-1) << "}"; s.op->assert_0_indent();