From e86310ea1294259f4e8c987ef92a1463ff09ab53 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 20 May 2013 16:50:00 +0400 Subject: [PATCH] [REFACTOR] move and rename uninstall_us_proc_probes() rename: uninstall_us_proc_probes() --> sspt_proc_uninstall() move: from src/modules/driver/us_proc_inst.c to src/modules/driver/sspt/sspt_proc.c --- driver/helper.c | 4 ++-- driver/sspt/sspt_proc.c | 17 +++++++++++++++++ driver/sspt/sspt_proc.h | 1 + driver/us_proc_inst.c | 18 +----------------- driver/us_proc_inst.h | 1 - 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/driver/helper.c b/driver/helper.c index 7138df5..0b9d868 100644 --- a/driver/helper.c +++ b/driver/helper.c @@ -89,7 +89,7 @@ static struct kretprobe pf_kretprobe = { static void recover_child(struct task_struct *child_task, struct sspt_proc *proc) { - uninstall_us_proc_probes(child_task, proc, US_DISARM); + sspt_proc_uninstall(proc, child_task, US_DISARM); dbi_disarm_urp_inst_for_task(current, child_task); } @@ -147,7 +147,7 @@ static int mr_pre_handler(struct kprobe *p, struct pt_regs *regs) proc = sspt_proc_get_by_task(task); if (proc) { - int ret = uninstall_us_proc_probes(task, proc, US_UNREGS_PROBE); + int ret = sspt_proc_uninstall(proc, task, US_UNREGS_PROBE); if (ret != 0) { printk("failed to uninstall IPs (%d)!\n", ret); } diff --git a/driver/sspt/sspt_proc.c b/driver/sspt/sspt_proc.c index 93c72a3..44c81fa 100644 --- a/driver/sspt/sspt_proc.c +++ b/driver/sspt/sspt_proc.c @@ -22,6 +22,7 @@ * */ +#include "sspt.h" #include "sspt_proc.h" #include "sspt_page.h" #include @@ -253,3 +254,19 @@ void sspt_proc_install(struct sspt_proc *proc) mm_read_unlock(mm, atomic, lock); } + +int sspt_proc_uninstall(struct sspt_proc *proc, struct task_struct *task, enum US_FLAGS flag) +{ + int err = 0; + struct sspt_file *file; + + list_for_each_entry_rcu(file, &proc->file_list, list) { + err = sspt_file_uninstall(file, task, flag); + if (err != 0) { + printk("ERROR sspt_proc_uninstall: err=%d\n", err); + return err; + } + } + + return err; +} diff --git a/driver/sspt/sspt_proc.h b/driver/sspt/sspt_proc.h index 453e004..cbd151e 100644 --- a/driver/sspt/sspt_proc.h +++ b/driver/sspt/sspt_proc.h @@ -59,5 +59,6 @@ struct sspt_file *sspt_proc_find_file_or_new(struct sspt_proc *proc, void sspt_proc_install_page(struct sspt_proc *proc, unsigned long page_addr); void sspt_proc_install(struct sspt_proc *proc); +int sspt_proc_uninstall(struct sspt_proc *proc, struct task_struct *task, enum US_FLAGS flag); #endif /* __SSPT_PROC__ */ diff --git a/driver/us_proc_inst.c b/driver/us_proc_inst.c index 51025e8..6ab82ce 100644 --- a/driver/us_proc_inst.c +++ b/driver/us_proc_inst.c @@ -162,7 +162,7 @@ int deinst_usr_space_proc (void) for_each_process(task) { proc = sspt_proc_get_by_task(task); if (proc) { - int ret = uninstall_us_proc_probes(task, proc, US_UNREGS_PROBE); + int ret = sspt_proc_uninstall(proc, task, US_UNREGS_PROBE); if (ret) { EPRINTF ("failed to uninstall IPs (%d)!", ret); } @@ -222,22 +222,6 @@ int inst_usr_space_proc (void) void print_vma(struct mm_struct *mm); -int uninstall_us_proc_probes(struct task_struct *task, struct sspt_proc *proc, enum US_FLAGS flag) -{ - int err = 0; - struct sspt_file *file; - - list_for_each_entry_rcu(file, &proc->file_list, list) { - err = sspt_file_uninstall(file, task, flag); - if (err != 0) { - // TODO: - return err; - } - } - - return err; -} - void print_vma(struct mm_struct *mm) { struct vm_area_struct *vma; diff --git a/driver/us_proc_inst.h b/driver/us_proc_inst.h index f85a692..2b16dfd 100644 --- a/driver/us_proc_inst.h +++ b/driver/us_proc_inst.h @@ -51,7 +51,6 @@ int install_otg_ip(unsigned long addr, unsigned long jp_handler, uretprobe_handler_t rp_handler); -int uninstall_us_proc_probes(struct task_struct *task, struct sspt_proc *proc, enum US_FLAGS flag); int check_vma(struct vm_area_struct *vma); #endif /* !defined(__US_PROC_INST_H__) */ -- 2.7.4