[REFACTOR] create and used /un/install_all()
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 13 Jun 2013 08:49:49 +0000 (12:49 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 13 Jun 2013 09:04:25 +0000 (13:04 +0400)
us_manager/pf/pf_group.c
us_manager/us_manager.c

index f2606d7..3b12106 100644 (file)
@@ -210,37 +210,6 @@ int pf_unregister_probe(struct pf_group *pfg, struct dentry *dentry,
        return img_proc_del_ip(pfg->i_proc, dentry, offset);
 }
 
-void install_all(void)
-{
-
-}
-
-void uninstall_all(void)
-{
-//     struct pf_group *pfg;
-//     list_for_each_entry(pfg, &pfg_list, list) {
-//             struct task_struct *task, ts;
-//
-//             rcu_read_lock();
-//             for_each_process(task) {
-//                     if (task->tgid != task->pid)
-//                             continue;
-//
-//                     if (is_kthread(task))
-//                             continue;
-//
-//                     ts = check_task_f(pfg->filter, task);
-//
-//                     if (ts) {
-//                             proc = sspt_proc_get_by_task_or_new(ts);
-//                             sspt_proc_install(proc);
-//                     }
-//             }
-//             rcu_read_unlock();
-//     }
-}
-
-
 static void install_page_by_pfg(unsigned long addr, struct task_struct *task,
                                struct pf_group *pfg)
 {
@@ -307,6 +276,65 @@ void uninstall_page(unsigned long addr)
 
 }
 
+void install_all(void)
+{
+       struct pf_group *pfg;
+       struct sspt_proc *proc;
+       struct task_struct *task;
+       int tmp_oops_in_progress;
+
+       tmp_oops_in_progress = oops_in_progress;
+       oops_in_progress = 1;
+       rcu_read_lock();
+       for_each_process(task) {
+               if (task->tgid != task->pid)
+                       continue;
+
+               if (is_kthread(task))
+                       continue;
+
+               list_for_each_entry(pfg, &pfg_list, list) {
+                       if (check_task_f(pfg->filter, task)) {
+                               proc = sspt_proc_get_by_task_or_new(task);
+                               sspt_proc_install(proc);
+                       }
+               }
+       }
+       rcu_read_unlock();
+       oops_in_progress = tmp_oops_in_progress;
+}
+
+static void clean_pfg(void)
+{
+       struct pf_group *pfg, *n;
+       struct proc_filter *filter;
+
+       list_for_each_entry_safe(pfg, n, &pfg_list, list) {
+               list_del(&pfg->list);
+               free_pfg(pfg);
+       }
+}
+
+void uninstall_all(void)
+{
+       int tmp_oops_in_progress;
+       struct task_struct *task;
+
+       tmp_oops_in_progress = oops_in_progress;
+       oops_in_progress = 1;
+       rcu_read_lock();
+       for_each_process(task) {
+               if (is_kthread(task))
+                       continue;
+
+               call_mm_release(task);
+       }
+       rcu_read_unlock();
+       oops_in_progress = tmp_oops_in_progress;
+
+       clean_pfg();
+}
+
 /* debug */
 void pfg_print(struct pf_group *pfg)
 {
index 737437f..526149e 100644 (file)
@@ -88,6 +88,8 @@ int usm_stop(void)
        if (iRet)
                printk("uninstall_kernel_probe(do_munmap) result=%d!\n", iRet);
 
+       uninstall_all();
+
 /*
        tmp_oops_in_progress = oops_in_progress;
        oops_in_progress = 1;
@@ -129,6 +131,8 @@ int usm_start(void)
                return ret;
        }
 
+       install_all();
+
 /*
        tmp_oops_in_progress = oops_in_progress;
        oops_in_progress = 1;