From e6290d309c65cdd7d3fe0124397550cbd9a3cb51 Mon Sep 17 00:00:00 2001 From: Dmitry Kovalenko Date: Wed, 22 May 2013 14:05:32 +0400 Subject: [PATCH] [FIX] not set retprobe for sys_exit Related to f8fa40b9f377164f117eeec47832b5b3351b4ec5, where retprobe for do_exit is not set. These function do not return by design --- kprobe/arch/dbi_kprobes.c | 4 +++- kprobe/dbi_kprobes.c | 3 +++ kprobe/dbi_kprobes_deps.c | 1 + kprobe/dbi_kprobes_deps.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kprobe/arch/dbi_kprobes.c b/kprobe/arch/dbi_kprobes.c index 3b6cac5..bcf2bf0 100644 --- a/kprobe/arch/dbi_kprobes.c +++ b/kprobe/arch/dbi_kprobes.c @@ -109,12 +109,14 @@ int arch_init_module_dependencies(void) exit_addr = swap_ksyms("do_exit"); sys_exit_group_addr = swap_ksyms("sys_exit_group"); do_group_exit_addr = swap_ksyms("do_group_exit"); + sys_exit_addr = swap_ksyms("sys_exit"); if ((void *)sched_addr == NULL || (void *)fork_addr == NULL || (void *)exit_addr == NULL || (void *)sys_exit_group_addr == NULL || - (void *)do_group_exit_addr == NULL) { + (void *)do_group_exit_addr == NULL || + (void *)sys_exit_addr == NULL) { return -ESRCH; } diff --git a/kprobe/dbi_kprobes.c b/kprobe/dbi_kprobes.c index 3ef525d..c0519f2 100644 --- a/kprobe/dbi_kprobes.c +++ b/kprobe/dbi_kprobes.c @@ -713,6 +713,9 @@ int dbi_register_kretprobe (struct kretprobe *rp) } else if ((unsigned long)rp->kp.addr == sys_exit_group_addr) { rp->kp.pre_handler = NULL; rp->maxactive = 0; + } else if ((unsigned long)rp->kp.addr == sys_exit_addr) { + rp->kp.pre_handler = NULL; + rp->maxactive = 0; } else if (rp->maxactive <= 0) { #if 1//def CONFIG_PREEMPT rp->maxactive = max (COMMON_RP_NR, 2 * NR_CPUS); diff --git a/kprobe/dbi_kprobes_deps.c b/kprobe/dbi_kprobes_deps.c index 87421e2..4f0fa7a 100644 --- a/kprobe/dbi_kprobes_deps.c +++ b/kprobe/dbi_kprobes_deps.c @@ -41,6 +41,7 @@ unsigned long fork_addr; unsigned long exit_addr; unsigned long sys_exit_group_addr; unsigned long do_group_exit_addr; +unsigned long sys_exit_addr; #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29) /* kernel define 'pgd_offset_k' redefinition */ diff --git a/kprobe/dbi_kprobes_deps.h b/kprobe/dbi_kprobes_deps.h index 706a1ef..2fb4b12 100644 --- a/kprobe/dbi_kprobes_deps.h +++ b/kprobe/dbi_kprobes_deps.h @@ -104,6 +104,7 @@ extern unsigned long fork_addr; extern unsigned long exit_addr; extern unsigned long sys_exit_group_addr; extern unsigned long do_group_exit_addr; +extern unsigned long sys_exit_addr; DECLARE_MOD_DEP_WRAPPER (__flush_anon_page, \ void, struct vm_area_struct *vma, \ -- 2.7.4