[IMPROVE] kernel with version > 4.0.0 support 50/72450/3
authorAnatolii Nikulin <nikulin.a@samsung.com>
Wed, 1 Jun 2016 05:43:12 +0000 (08:43 +0300)
committerAnatolii Nikulin <nikulin.a@samsung.com>
Fri, 3 Jun 2016 09:36:29 +0000 (12:36 +0300)
Change-Id: I185a64e561b85dca01f327ac0db52f5d4e8752b5
Signed-off-by: Anatolii Nikulin <nikulin.a@samsung.com>
kprobe/arch/x86/swap-asm/swap_kprobes.c
kprobe/arch/x86/swap-asm/swap_kprobes.h
kprobe/swap_kprobes_deps.c
loader/loader_module.c
preload/preload_module.c
sampler/swap_sampler_module.c
uprobe/arch/x86/swap-asm/swap_uprobes.c

index d8e615f..9e5d2ed 100644 (file)
@@ -719,7 +719,7 @@ static int kprobe_exceptions_notify(struct notifier_block *self,
 
        DBPRINTF("val = %ld, data = 0x%X", val, (unsigned int) data);
 
-       if (args->regs == NULL || user_mode_vm(args->regs))
+       if (args->regs == NULL || swap_user_mode(args->regs))
                return ret;
 
        DBPRINTF("switch (val) %lu %d %d", val, DIE_INT3, DIE_TRAP);
index 43f0f7a..bd1da71 100644 (file)
@@ -80,6 +80,15 @@ typedef u8 kprobe_opcode_t;
 #define KPROBES_TRAMP_LEN              MAX_INSN_SIZE
 #define KPROBES_TRAMP_INSN_IDX          0
 
+static inline int swap_user_mode(struct pt_regs *regs)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
+       return user_mode(regs);
+#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) */
+       return user_mode_vm(regs);
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) */
+}
+
 static inline unsigned long arch_get_task_pc(struct task_struct *p)
 {
        /* FIXME: Not implemented yet */
index 7ef1056..22561e9 100644 (file)
@@ -294,7 +294,17 @@ static inline int swap_in_gate_area(struct task_struct *task,
        IMP_MOD_DEP_WRAPPER(in_gate_area, task, addr)
 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
 #else /*__HAVE_ARCH_GATE_AREA */
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38)
+       struct mm_struct *mm;
+
+       if (task == NULL)
+               return 0;
+
+       mm = task->mm;
+       return in_gate_area(mm, addr);
+#else
        return in_gate_area(task, addr);
+#endif
 #endif/*__HAVE_ARCH_GATE_AREA */
 }
 
index d305b96..8b46f5f 100644 (file)
@@ -219,7 +219,7 @@ static struct vm_area_struct *__get_linker_vma(struct task_struct *task)
 
        for (vma = task->mm->mmap; vma; vma = vma->vm_next) {
                if (vma->vm_file && vma->vm_flags & VM_EXEC
-                   && vma->vm_file->f_dentry == ld_info->dentry) {
+                   && vma->vm_file->f_path.dentry == ld_info->dentry) {
                                ls_put_linker_info(ld_info);
                                return vma;
                }
@@ -324,7 +324,7 @@ static int mmap_entry_handler(struct kretprobe_instance *ri,
        if (!file)
                return 0;
 
-       dentry = file->f_dentry;
+       dentry = file->f_path.dentry;
        if (dentry == NULL)
                return 0;
 
index 71a7fab..e1c1f0c 100644 (file)
@@ -141,9 +141,9 @@ static unsigned long __do_preload_entry(struct uretprobe_instance *ri,
                /* jump only if caller is instumented and it is not a system lib -
                 * this leads to some errors */
                if (cvma != NULL && cvma->vm_file != NULL &&
-                       cvma->vm_file->f_dentry != NULL) {
+                       cvma->vm_file->f_path.dentry != NULL) {
 
-                       struct dentry *dentry = cvma->vm_file->f_dentry;
+                       struct dentry *dentry = cvma->vm_file->f_path.dentry;
                        struct pd_t *pd = lpd_get_parent_pd(hd);
 
                        if (!pc_check_dentry_is_ignored(dentry) &&
index c1a2b27..94cb506 100644 (file)
@@ -74,7 +74,7 @@ static void swap_timer_stop(void)
        put_online_cpus();
 }
 
-static int __cpuinit swap_cpu_notify(struct notifier_block *self,
+static int swap_cpu_notify(struct notifier_block *self,
                                    unsigned long action, void *hcpu)
 {
        long cpu = (long) hcpu;
index c6b5151..97daf85 100644 (file)
@@ -617,7 +617,7 @@ static int uprobe_exceptions_notify(struct notifier_block *self,
        struct die_args *args = (struct die_args *)data;
        int ret = NOTIFY_DONE;
 
-       if (args->regs == NULL || !user_mode_vm(args->regs))
+       if (args->regs == NULL || !swap_user_mode(args->regs))
                return ret;
 
        switch (val) {