for (page_addr = vma->vm_start; page_addr < vma->vm_end; page_addr += PAGE_SIZE) {
page = sspt_find_page_mapped(file, page_addr);
if (page) {
- unregister_us_page_probe(task, page, US_UNREGS_PROBE);
+ sspt_unregister_page(page, US_UNREGS_PROBE, task);
}
}
*
*/
+#include <dbi_kprobes_deps.h>
+
static inline void print_jprobe(struct jprobe *jp)
{
printk("### JP: entry=%lx, pre_entry=%lx\n",
printk("### print_proc_probes\n");
}
+/*
static inline void print_inst_us_proc(const inst_us_proc_t *task_inst_info)
{
int i;
}
printk("### BUNDLE PRINT END ###\n");
}
+*/
#endif /* __SSPT_DEBUG__ */
*
*/
+#include "sspt.h"
#include "sspt_page.h"
#include "sspt_file.h"
#include "ip.h"
ip->retprobe.up.kp.addr = ip->jprobe.up.kp.addr = (kprobe_opcode_t *)addr;
}
}
+
+int sspt_register_page(struct sspt_page *page,
+ struct sspt_file *file,
+ struct task_struct *task)
+{
+ int err = 0;
+ struct us_ip *ip, *n;
+
+ spin_lock(&page->lock);
+
+ if (sspt_page_is_install(page)) {
+ printk("page %lx in %s task[tgid=%u, pid=%u] already installed\n",
+ page->offset, file->dentry->d_iname, task->tgid, task->pid);
+ goto unlock;
+ }
+
+ sspt_page_assert_install(page);
+ sspt_set_all_ip_addr(page, file);
+
+ list_for_each_entry_safe(ip, n, &page->ip_list, list) {
+ err = sspt_register_usprobe(task, ip);
+ if (err == -ENOEXEC) {
+ list_del(&ip->list);
+ free_ip(ip);
+ continue;
+ } else if (err) {
+ printk("Failed to install probe\n");
+ }
+ }
+unlock:
+ sspt_page_installed(page);
+ spin_unlock(&page->lock);
+
+ return 0;
+}
+
+int sspt_unregister_page(struct sspt_page *page,
+ enum US_FLAGS flag,
+ struct task_struct *task)
+{
+ int err = 0;
+ struct us_ip *ip;
+
+ spin_lock(&page->lock);
+ if (!sspt_page_is_install(page)) {
+ spin_unlock(&page->lock);
+ return 0;
+ }
+
+ list_for_each_entry(ip, &page->ip_list, list) {
+ err = sspt_unregister_usprobe(task, ip, flag);
+ if (err != 0) {
+ //TODO: ERROR
+ break;
+ }
+ }
+
+ if (flag != US_DISARM) {
+ sspt_page_uninstalled(page);
+ }
+ spin_unlock(&page->lock);
+
+ return err;
+}
struct us_ip;
struct sspt_file;
+struct task_struct;
+enum US_FLAGS;
struct sspt_page {
struct list_head ip_list;
void sspt_set_all_ip_addr(struct sspt_page *page, const struct sspt_file *file);
+int sspt_register_page(struct sspt_page *page,
+ struct sspt_file *file,
+ struct task_struct *task);
+
+int sspt_unregister_page(struct sspt_page *page,
+ enum US_FLAGS flag,
+ struct task_struct *task);
+
#endif /* __SSPT_PAGE__ */
void print_vma(struct mm_struct *mm);
-static int register_us_page_probe(struct sspt_page *page,
- const struct sspt_file *file,
- struct task_struct *task)
-{
- int err = 0;
- struct us_ip *ip, *n;
-
- spin_lock(&page->lock);
-
- if (sspt_page_is_install(page)) {
- printk("page %lx in %s task[tgid=%u, pid=%u] already installed\n",
- page->offset, file->dentry->d_iname, task->tgid, task->pid);
- print_vma(task->mm);
- goto unlock;
- }
-
- sspt_page_assert_install(page);
- sspt_set_all_ip_addr(page, file);
-
- list_for_each_entry_safe(ip, n, &page->ip_list, list) {
- err = sspt_register_usprobe(task, ip);
- if (err == -ENOEXEC) {
- list_del(&ip->list);
- free_ip(ip);
- continue;
- } else if (err) {
- EPRINTF("Failed to install probe");
- }
- }
-unlock:
- sspt_page_installed(page);
- spin_unlock(&page->lock);
-
- return 0;
-}
-
-int unregister_us_page_probe(struct task_struct *task,
- struct sspt_page *page, enum US_FLAGS flag)
-{
- int err = 0;
- struct us_ip *ip;
-
- spin_lock(&page->lock);
- if (!sspt_page_is_install(page)) {
- spin_unlock(&page->lock);
- return 0;
- }
-
- list_for_each_entry(ip, &page->ip_list, list) {
- err = sspt_unregister_usprobe(task, ip, flag);
- if (err != 0) {
- //TODO: ERROR
- break;
- }
- }
-
- if (flag != US_DISARM) {
- sspt_page_uninstalled(page);
- }
- spin_unlock(&page->lock);
-
- return err;
-}
-
void install_page_probes(unsigned long page_addr, struct task_struct *task, struct sspt_procs *procs)
{
int lock, atomic;
page = sspt_find_page_mapped(file, page_addr);
if (page) {
- register_us_page_probe(page, file, task);
+ sspt_register_page(page, file, task);
}
}
}
for (i = 0; i < table_size; ++i) {
head = &file->page_probes_table[i];
swap_hlist_for_each_entry_rcu(page, node, head, hlist) {
- register_us_page_probe(page, file, task);
+ sspt_register_page(page, file, task);
}
}
}
for (i = 0; i < table_size; ++i) {
head = &file->page_probes_table[i];
swap_hlist_for_each_entry_safe (page, node, tmp, head, hlist) {
- err = unregister_us_page_probe(task, page, flag);
+ err = sspt_unregister_page(page, flag, task);
if (err != 0) {
// TODO: ERROR
return err;
int check_install_pages_in_file(struct task_struct *task, struct sspt_file *file);
-int unregister_us_page_probe(struct task_struct *task,
- struct sspt_page *page, enum US_FLAGS flag);
void install_proc_probes(struct task_struct *task, struct sspt_procs *procs);
pid_t find_proc_by_task(const struct task_struct *task, struct dentry *dentry);
void install_page_probes(unsigned long page_addr, struct task_struct *task, struct sspt_procs *procs);