From: Vyacheslav Cherkashin Date: Thu, 1 Oct 2015 13:04:12 +0000 (+0300) Subject: [FIX] disarm uretprobe from child process X-Git-Tag: accepted/tizen/2.4/mobile/20151029.024950~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F19%2F48919%2F2;p=kernel%2Fswap-modules.git [FIX] disarm uretprobe from child process get_user can be used only if task->mm == current->mm So for other case let call *_proc_vm_atomic() Change-Id: I227da7e2ccfcb70fb3dd27b54f5ec4ad1056296e Signed-off-by: Vyacheslav Cherkashin --- diff --git a/uprobe/arch/x86/swap-asm/swap_uprobes.c b/uprobe/arch/x86/swap-asm/swap_uprobes.c index 518c304..352d75c 100644 --- a/uprobe/arch/x86/swap-asm/swap_uprobes.c +++ b/uprobe/arch/x86/swap-asm/swap_uprobes.c @@ -208,6 +208,24 @@ int arch_prepare_uretprobe(struct uretprobe_instance *ri, struct pt_regs *regs) return 0; } +static bool get_long(struct task_struct *task, + unsigned long vaddr, unsigned long *val) +{ + return task->mm == current->mm ? + !!get_user(*val, (unsigned long *)vaddr) : + sizeof(*val) != read_proc_vm_atomic(task, vaddr, + val, sizeof(*val)); +} + +static bool put_long(struct task_struct *task, + unsigned long vaddr, unsigned long *val) +{ + return task->mm == current->mm ? + !!put_user(*val, (unsigned long *)vaddr) : + sizeof(*val) != write_proc_vm_atomic(task, vaddr, + val, sizeof(*val)); +} + /** * @brief Disarms uretprobe on x86 arch. * @@ -228,14 +246,14 @@ int arch_disarm_urp_inst(struct uretprobe_instance *ri, else tramp_addr = tr; /* ri - invalid */ - if (get_user(ret_addr, (unsigned long *)sp)) { + if (get_long(task, sp, &ret_addr)) { printk(KERN_INFO "---> %s (%d/%d): failed to read stack from %08lx\n", task->comm, task->tgid, task->pid, sp); return -EFAULT; } if (tramp_addr == ret_addr) { - if (put_user((unsigned long)ri->ret_addr, (unsigned long *)sp)) { + if (put_long(task, sp, (unsigned long *)&ri->ret_addr)) { printk(KERN_INFO "---> %s (%d/%d): failed to write " "orig_ret_addr to %08lx", task->comm, task->tgid, task->pid, sp);