summaryrefslogtreecommitdiffstats
path: root/runtime/uprobes/uprobes.c
diff options
context:
space:
mode:
authorkenistoj <kenistoj>2008-01-19 00:24:07 +0000
committerkenistoj <kenistoj>2008-01-19 00:24:07 +0000
commit7abdfe546471945b393fc4ff4a955b8e7b2a0ac2 (patch)
tree01f04f12d43b7f081372489852c516ea01be6e17 /runtime/uprobes/uprobes.c
parentbfe2b4ab0a801c23b130b5083b7fbf5c00ab004a (diff)
downloadsystemtap-steved-7abdfe546471945b393fc4ff4a955b8e7b2a0ac2.tar.gz
systemtap-steved-7abdfe546471945b393fc4ff4a955b8e7b2a0ac2.tar.xz
systemtap-steved-7abdfe546471945b393fc4ff4a955b8e7b2a0ac2.zip
* runtime/uprobes/uprobes.c: Added static copy of
access_process_vm(), for kernels that don't export it.
Diffstat (limited to 'runtime/uprobes/uprobes.c')
-rw-r--r--runtime/uprobes/uprobes.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/runtime/uprobes/uprobes.c b/runtime/uprobes/uprobes.c
index 50930709..005ca919 100644
--- a/runtime/uprobes/uprobes.c
+++ b/runtime/uprobes/uprobes.c
@@ -42,8 +42,14 @@
#define MAX_SSOL_SLOTS 1024
+#ifdef NO_ACCESS_PROCESS_VM_EXPORT
+static int __access_process_vm(struct task_struct *tsk, unsigned long addr,
+ void *buf, int len, int write);
+#define access_process_vm __access_process_vm
+#else
extern int access_process_vm(struct task_struct *tsk, unsigned long addr,
void *buf, int len, int write);
+#endif
static int utask_fake_quiesce(struct uprobe_task *utask);
static void uprobe_release_ssol_vma(struct uprobe_process *uproc);
@@ -2267,5 +2273,61 @@ static void zap_uretprobe_instances(struct uprobe *u,
}
#endif /* CONFIG_URETPROBES */
+#ifdef NO_ACCESS_PROCESS_VM_EXPORT
+/*
+ * Some kernel versions export everything that uprobes.ko needs except
+ * access_process_vm, so we copied and pasted it here. Fortunately,
+ * everything it calls is exported.
+ */
+#include <linux/pagemap.h>
+#include <asm/cacheflush.h>
+static int __access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
+{
+ struct mm_struct *mm;
+ struct vm_area_struct *vma;
+ struct page *page;
+ void *old_buf = buf;
+
+ mm = get_task_mm(tsk);
+ if (!mm)
+ return 0;
+
+ down_read(&mm->mmap_sem);
+ /* ignore errors, just check how much was sucessfully transfered */
+ while (len) {
+ int bytes, ret, offset;
+ void *maddr;
+
+ ret = get_user_pages(tsk, mm, addr, 1,
+ write, 1, &page, &vma);
+ if (ret <= 0)
+ break;
+
+ bytes = len;
+ offset = addr & (PAGE_SIZE-1);
+ if (bytes > PAGE_SIZE-offset)
+ bytes = PAGE_SIZE-offset;
+
+ maddr = kmap(page);
+ if (write) {
+ copy_to_user_page(vma, page, addr,
+ maddr + offset, buf, bytes);
+ set_page_dirty_lock(page);
+ } else {
+ copy_from_user_page(vma, page, addr,
+ buf, maddr + offset, bytes);
+ }
+ kunmap(page);
+ page_cache_release(page);
+ len -= bytes;
+ buf += bytes;
+ addr += bytes;
+ }
+ up_read(&mm->mmap_sem);
+ mmput(mm);
+
+ return buf - old_buf;
+}
+#endif
#include "uprobes_arch.c"
MODULE_LICENSE("GPL");