#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)
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;
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,
+++ /dev/null
-#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;
-}
+++ /dev/null
-#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__ */