From: Kris Van Hees Date: Wed, 14 Aug 2013 12:44:01 +0000 (-0400) Subject: dtrace: Bug fix for logic to determine the (inode, offset) pair for uprobes. X-Git-Tag: v4.1.12-92~313^2~68 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c2541ab269cb8d6f26ee14622259e14d77998e17;p=users%2Fjedix%2Flinux-maple.git dtrace: Bug fix for logic to determine the (inode, offset) pair for uprobes. The logic used to determine the (inode, offset) pair needed by uprobes, and caculated based on an address in a process memory space. was flawed. This caused USDT probes in shared libraries to not work correctly. Signed-off-by: Kris Van Hees --- diff --git a/kernel/dtrace/dtrace_os.c b/kernel/dtrace/dtrace_os.c index 1f5d923db988..221aa3893330 100644 --- a/kernel/dtrace/dtrace_os.c +++ b/kernel/dtrace/dtrace_os.c @@ -990,9 +990,7 @@ void dtrace_task_cleanup(struct task_struct *tsk) (*dtrace_helpers_cleanup)(tsk); if (tsk->dtrace_probes) { - if (dtrace_fasttrap_probes_cleanup == NULL) - pr_warn("Fasttrap probes, yet no cleanup routine\n"); - else + if (dtrace_fasttrap_probes_cleanup != NULL) (*dtrace_fasttrap_probes_cleanup)(tsk); } } @@ -1031,30 +1029,26 @@ int dtrace_tracepoint_enable(pid_t pid, uintptr_t addr, return -ESRCH; } - vma = p->mm->mmap; - if (vma->vm_file == NULL) { - pr_warn("DTRACE: vma->vm_file is NULL\n"); + vma = find_vma(p->mm, addr); + if (vma == NULL || vma->vm_file == NULL) return -ESRCH; - } ino = vma->vm_file->f_mapping->host; off = ((loff_t)vma->vm_pgoff << PAGE_SHIFT) + (addr - vma->vm_start); - if (((uintptr_t)ino & 0xffff880000000000ULL) == 0xffff880000000000ULL) { - mtp->fmtp_cns.handler = handler; + mtp->fmtp_cns.handler = handler; - rc = uprobe_register(ino, off, &mtp->fmtp_cns); + rc = uprobe_register(ino, off, &mtp->fmtp_cns); - /* - * If successful, increment the count of the number of - * tracepoints active in the victim process. - */ - if (rc == 0) { - mtp->fmtp_ino = ino; - mtp->fmtp_off = off; + /* + * If successful, increment the count of the number of + * tracepoints active in the victim process. + */ + if (rc == 0) { + mtp->fmtp_ino = ino; + mtp->fmtp_off = off; - p->dtrace_tp_count++; - } + p->dtrace_tp_count++; } return rc;