[FIX] Preload: use get_user to obtain current linker state 49/46849/4
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Sat, 22 Aug 2015 11:44:19 +0000 (14:44 +0300)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Fri, 28 Aug 2015 06:06:23 +0000 (23:06 -0700)
Change-Id: I90bd7d09c6106a3324fa810d5cdc344a122a49c7
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
preload/Kbuild
preload/preload_debugfs.c
preload/preload_module.c
preload/preload_patcher.c [deleted file]
preload/preload_patcher.h [deleted file]
preload/preload_threads.c

index 6d6cf84..84aa787 100644 (file)
@@ -7,5 +7,4 @@ swap_preload-y := preload_module.o \
                   preload_probe.o \
                   preload_control.o \
                   preload_threads.o \
-                  preload_patcher.o \
                   preload_pd.o
index 9e412c9..caeb022 100644 (file)
@@ -12,7 +12,6 @@
 #include "preload_debugfs.h"
 #include "preload_module.h"
 #include "preload_control.h"
-#include "preload_patcher.h"
 #include "preload_storage.h"
 
 static const char PRELOAD_FOLDER[] = "preload";
index 4269000..547edf9 100644 (file)
@@ -27,7 +27,6 @@
 #include "preload_storage.h"
 #include "preload_control.h"
 #include "preload_threads.h"
-#include "preload_patcher.h"
 #include "preload_pd.h"
 
 #define page_to_proc(page) ((page)->file->proc)
@@ -377,7 +376,7 @@ static bool __is_proc_mmap_mappable(struct task_struct *task)
        struct vm_area_struct *linker_vma = __get_linker_vma(task);
        unsigned long r_debug_addr;
        unsigned int state;
-       int ret;
+       enum { r_state_offset = sizeof(int) + sizeof(void *) + sizeof(long) };
 
        if (linker_vma == NULL)
                return false;
@@ -386,13 +385,11 @@ static bool __is_proc_mmap_mappable(struct task_struct *task)
        if (r_debug_addr == 0)
                return false;
 
-       ret = preload_patcher_get_ui((void *)r_debug_addr + sizeof(int) +
-                                sizeof(void *) + sizeof(unsigned long),
-                                &state, task);
-       if (ret != sizeof(state))
+       r_debug_addr += r_state_offset;
+       if (get_user(state, (unsigned long *)r_debug_addr))
                return false;
 
-       return ( state == 0 ? true : false );
+       return !state;
 }
 
 static bool __not_system_caller(struct task_struct *task,
diff --git a/preload/preload_patcher.c b/preload/preload_patcher.c
deleted file mode 100644 (file)
index d2457b7..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/mm_types.h>
-#include <linux/mm.h>
-
-#include <kprobe/swap_kprobes_deps.h>
-
-#include "preload_patcher.h"
-#include "preload_debugfs.h"
-#include "preload_storage.h"
-
-
-static inline bool check_vma(struct vm_area_struct *vma, struct dentry *dentry)
-{
-       struct file *file = vma->vm_file;
-
-       return (file && (vma->vm_flags & VM_EXEC) && (file->f_dentry == dentry));
-}
-
-
-static inline int __patch_proc_mem(struct task_struct *task, unsigned long addr,
-                                  void *buf, int size)
-{
-       return write_proc_vm_atomic(task, addr, buf, size);
-}
-
-static inline int __read_proc_mem(struct task_struct *task, unsigned long addr,
-                                 void *value, size_t value_size)
-{
-       return read_proc_vm_atomic(task, addr, value, value_size);
-}
-
-
-
-
-int preload_patcher_patch_proc(void *addr, unsigned long val,
-                              struct task_struct *task)
-{
-       return __patch_proc_mem(task, (unsigned long)addr, &val, sizeof(val));
-}
-
-int preload_patcher_write_string(void *addr, char *string, size_t len,
-                                struct task_struct *task)
-{
-       return __patch_proc_mem(task, (unsigned long)addr, string, len);
-}
-
-int preload_patcher_get_ul(void *addr, unsigned long *val,
-                          struct task_struct *task)
-{
-       return __read_proc_mem(task, (unsigned long)addr, val, sizeof(*val));
-}
-
-int preload_patcher_get_ui(void *addr, unsigned int *val,
-                          struct task_struct *task)
-{
-       return __read_proc_mem(task, (unsigned long)addr, val, sizeof(*val));
-}
-
-int preload_patcher_null_mem(void *addr, int size, struct task_struct *task)
-{
-       char *buf;
-       int ret;
-
-       buf = kmalloc(size, GFP_KERNEL);
-       if (buf == NULL)
-               return -ENOMEM;
-
-       memset(buf, 0, size);
-
-       ret = __patch_proc_mem(task, (unsigned long)addr, buf, size);
-
-       kfree(buf);
-
-       return ret;
-}
diff --git a/preload/preload_patcher.h b/preload/preload_patcher.h
deleted file mode 100644 (file)
index 492a2c0..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef __PRELOAD_PATCHER_H__
-#define __PRELOAD_PATCHER_H__
-
-struct task_struct;
-
-int preload_patcher_patch_proc(void *addr, unsigned long val,
-                               struct task_struct *task);
-int preload_patcher_write_string(void *addr, char *string, size_t len,
-                                 struct task_struct *task);
-int preload_patcher_get_ul(void *addr, unsigned long *val,
-                           struct task_struct *task);
-int preload_patcher_null_mem(void *addr, int size, struct task_struct *task);
-int preload_patcher_get_ui(void *addr, unsigned int *val,
-                           struct task_struct *task);
-
-
-
-#endif /* __PRELOAD_PATCHER_H__ */
index 7c881d4..20840ac 100644 (file)
@@ -9,7 +9,6 @@
 #include "preload.h"
 #include "preload_threads.h"
 #include "preload_debugfs.h"
-#include "preload_patcher.h"
 #include "preload_pd.h"
 
 struct preload_td {