extern struct list_head proc_probes_list;
-struct proc_probes *proc_p_create(struct dentry* dentry, pid_t tgid)
+struct sspt_procs *proc_p_create(struct dentry* dentry, pid_t tgid)
{
- struct proc_probes *proc_p = kmalloc(sizeof(*proc_p), GFP_ATOMIC);
+ struct sspt_procs *procs = kmalloc(sizeof(*procs), GFP_ATOMIC);
- if (proc_p) {
- INIT_LIST_HEAD(&proc_p->list);
- proc_p->tgid = tgid;
- proc_p->dentry = dentry;
- INIT_LIST_HEAD(&proc_p->file_list);
+ if (procs) {
+ INIT_LIST_HEAD(&procs->list);
+ procs->tgid = tgid;
+ procs->dentry = dentry;
+ INIT_LIST_HEAD(&procs->file_list);
}
- return proc_p;
+ return procs;
}
-void proc_p_free(struct proc_probes *proc_p)
+void proc_p_free(struct sspt_procs *procs)
{
struct file_probes *file_p, *n;
- list_for_each_entry_safe(file_p, n, &proc_p->file_list, list) {
+ list_for_each_entry_safe(file_p, n, &procs->file_list, list) {
list_del(&file_p->list);
file_p_del(file_p);
}
- kfree(proc_p);
+ kfree(procs);
}
// TODO: remove "us_proc_info"
us_proc_info.pp = NULL;
} else {
// libonly
- struct proc_probes *proc_p, *n;
- list_for_each_entry_safe(proc_p, n, &proc_probes_list, list) {
- list_del(&proc_p->list);
- proc_p_free(proc_p);
+ struct sspt_procs *procs, *n;
+ list_for_each_entry_safe(procs, n, &proc_probes_list, list) {
+ list_del(&procs->list);
+ proc_p_free(procs);
}
}
}
-static void proc_p_add_file_p(struct proc_probes *proc_p, struct file_probes *file_p)
+static void proc_p_add_file_p(struct sspt_procs *procs, struct file_probes *file_p)
{
- list_add(&file_p->list, &proc_p->file_list);
+ list_add(&file_p->list, &procs->file_list);
}
-struct file_probes *proc_p_find_file_p_by_dentry(struct proc_probes *proc_p,
+struct file_probes *proc_p_find_file_p_by_dentry(struct sspt_procs *procs,
const char *pach, struct dentry *dentry)
{
struct file_probes *file_p;
- list_for_each_entry(file_p, &proc_p->file_list, list) {
+ list_for_each_entry(file_p, &procs->file_list, list) {
if (file_p->dentry == dentry) {
return file_p;
}
}
file_p = file_p_new(pach, dentry, 10);
- proc_p_add_file_p(proc_p, file_p);
+ proc_p_add_file_p(procs, file_p);
return file_p;
}
-void proc_p_add_dentry_probes(struct proc_probes *proc_p, const char *pach,
+void proc_p_add_dentry_probes(struct sspt_procs *procs, const char *pach,
struct dentry* dentry, struct ip_data *ip_d, int cnt)
{
int i;
- struct file_probes *file_p = proc_p_find_file_p_by_dentry(proc_p, pach, dentry);
+ struct file_probes *file_p = proc_p_find_file_p_by_dentry(procs, pach, dentry);
for (i = 0; i < cnt; ++i) {
file_p_add_probe(file_p, &ip_d[i]);
}
}
-struct proc_probes *proc_p_copy(struct proc_probes *proc_p, struct task_struct *task)
+struct sspt_procs *proc_p_copy(struct sspt_procs *procs, struct task_struct *task)
{
struct file_probes *file_p;
- struct proc_probes *proc_p_out = proc_p_create(proc_p->dentry, task->tgid);
+ struct sspt_procs *procs_out = proc_p_create(procs->dentry, task->tgid);
- list_for_each_entry(file_p, &proc_p->file_list, list) {
- proc_p_add_file_p(proc_p_out, file_p_copy(file_p));
+ list_for_each_entry(file_p, &procs->file_list, list) {
+ proc_p_add_file_p(procs_out, file_p_copy(file_p));
}
- return proc_p_out;
+ return procs_out;
}
-struct file_probes *proc_p_find_file_p(struct proc_probes *proc_p, struct vm_area_struct *vma)
+struct file_probes *proc_p_find_file_p(struct sspt_procs *procs, struct vm_area_struct *vma)
{
struct file_probes *file_p;
- list_for_each_entry(file_p, &proc_p->file_list, list) {
+ list_for_each_entry(file_p, &procs->file_list, list) {
if (vma->vm_file->f_dentry == file_p->dentry) {
return file_p;
}
return !!us_proc_info.path;
}
-struct proc_probes *get_proc_probes_by_task(struct task_struct *task)
+struct sspt_procs *get_proc_probes_by_task(struct task_struct *task)
{
- struct proc_probes *proc_p, *tmp;
+ struct sspt_procs *procs, *tmp;
if (!is_libonly()) {
if (task != current) {
return us_proc_info.pp;
}
- list_for_each_entry_safe(proc_p, tmp, &proc_probes_list, list) {
- if (proc_p->tgid == task->tgid) {
- return proc_p;
+ list_for_each_entry_safe(procs, tmp, &proc_probes_list, list) {
+ if (procs->tgid == task->tgid) {
+ return procs;
}
}
return NULL;
}
-void add_proc_probes(struct task_struct *task, struct proc_probes *proc_p)
+void add_proc_probes(struct task_struct *task, struct sspt_procs *procs)
{
- list_add_tail(&proc_p->list, &proc_probes_list);
+ list_add_tail(&procs->list, &proc_probes_list);
}
-struct proc_probes *get_proc_probes_by_task_or_new(struct task_struct *task)
+struct sspt_procs *get_proc_probes_by_task_or_new(struct task_struct *task)
{
- struct proc_probes *proc_p = get_proc_probes_by_task(task);
- if (proc_p == NULL) {
- proc_p = proc_p_copy(us_proc_info.pp, task);
- add_proc_probes(task, proc_p);
+ struct sspt_procs *procs = get_proc_probes_by_task(task);
+ if (procs == NULL) {
+ procs = proc_p_copy(us_proc_info.pp, task);
+ add_proc_probes(task, procs);
}
- return proc_p;
+ return procs;
}
#ifdef SLP_APP
}
static void set_mapping_file(struct file_probes *file_p,
- const struct proc_probes *proc_p,
+ const struct sspt_procs *procs,
const struct task_struct *task,
const struct vm_area_struct *vma);
unsigned long offset_addr = addr - vma->vm_start;
struct dentry *dentry = vma->vm_file->f_dentry;
char *name = dentry->d_iname;
- struct proc_probes *proc_p = get_proc_probes_by_task(task);
+ struct sspt_procs *procs = get_proc_probes_by_task(task);
struct ip_data pd = {
.offset = offset_addr,
.pre_handler = pre_handler,
.flag_retprobe = 1
};
- struct file_probes *file_p = proc_p_find_file_p_by_dentry(proc_p, name, dentry);
+ struct file_probes *file_p = proc_p_find_file_p_by_dentry(procs, name, dentry);
struct page_probes *page_p = get_page_p(file_p, offset_addr);
struct us_ip *ip = page_p_find_ip(page_p, offset_addr & ~PAGE_MASK);
if (!file_p->loaded) {
- set_mapping_file(file_p, proc_p, task, vma);
+ set_mapping_file(file_p, procs, task, vma);
file_p->loaded = 1;
}
if (ip == NULL) {
- struct file_probes *file_p = proc_p_find_file_p_by_dentry(proc_p, name, dentry);
+ struct file_probes *file_p = proc_p_find_file_p_by_dentry(procs, name, dentry);
file_p_add_probe(file_p, &pd);
/* if addr mapping, that probe install, else it be installed in do_page_fault handler */
return iRet;
}
-static int uninstall_us_proc_probes(struct task_struct *task, struct proc_probes *proc_p, enum US_FLAGS flag);
+static int uninstall_us_proc_probes(struct task_struct *task, struct sspt_procs *procs, enum US_FLAGS flag);
int deinst_usr_space_proc (void)
{
EPRINTF ("uninstall_kernel_probe(do_munmap) result=%d!", iRet);
if (is_libonly()) {
- struct proc_probes *proc_p;
+ struct sspt_procs *procs;
for_each_process(task) {
- proc_p = get_proc_probes_by_task(task);
- if (proc_p) {
- int ret = uninstall_us_proc_probes(task, proc_p, US_UNREGS_PROBE);
+ procs = get_proc_probes_by_task(task);
+ if (procs) {
+ int ret = uninstall_us_proc_probes(task, procs, US_UNREGS_PROBE);
if (ret) {
EPRINTF ("failed to uninstall IPs (%d)!", ret);
}
return 0;
}
-static void install_proc_probes(struct task_struct *task, struct proc_probes *proc_p, int atomic);
+static void install_proc_probes(struct task_struct *task, struct sspt_procs *procs, int atomic);
int inst_usr_space_proc (void)
{
{
// FIXME: clear_task_inst_info();
for_each_process (task) {
- struct proc_probes *proc_p;
+ struct sspt_procs *procs;
if (task->flags & PF_KTHREAD){
DPRINTF("ignored kernel thread %d\n",
continue;
}
- proc_p = get_proc_probes_by_task_or_new(task);
+ procs = get_proc_probes_by_task_or_new(task);
DPRINTF("trying process");
#ifdef __ANDROID
if (is_java_inst_enabled()) {
find_libdvm_for_task(task, task_inst_info);
}
#endif /* __ANDROID */
- install_proc_probes(task, proc_p, 1);
+ install_proc_probes(task, procs, 1);
//put_task_struct (task);
}
}
EXPORT_SYMBOL_GPL (imi_sum_hit);
static void set_mapping_file(struct file_probes *file_p,
- const struct proc_probes *proc_p,
+ const struct sspt_procs *procs,
const struct task_struct *task,
const struct vm_area_struct *vma)
{
- int app_flag = (vma->vm_file->f_dentry == proc_p->dentry);
+ int app_flag = (vma->vm_file->f_dentry == procs->dentry);
char *p;
// if we installed something, post library info for those IPs
p = strrchr(file_p->path, '/');
}
-static void install_page_probes(unsigned long page, struct task_struct *task, struct proc_probes *proc_p, int atomic)
+static void install_page_probes(unsigned long page, struct task_struct *task, struct sspt_procs *procs, int atomic)
{
int lock;
struct mm_struct *mm;
vma = find_vma(mm, page);
if (vma && check_vma(vma)) {
- struct file_probes *file_p = proc_p_find_file_p(proc_p, vma);
+ struct file_probes *file_p = proc_p_find_file_p(procs, vma);
if (file_p) {
struct page_probes *page_p;
if (!file_p->loaded) {
- set_mapping_file(file_p, proc_p, task, vma);
+ set_mapping_file(file_p, procs, task, vma);
file_p->loaded = 1;
}
}
}
-static void install_proc_probes(struct task_struct *task, struct proc_probes *proc_p, int atomic)
+static void install_proc_probes(struct task_struct *task, struct sspt_procs *procs, int atomic)
{
int lock;
struct vm_area_struct *vma;
for (vma = mm->mmap; vma; vma = vma->vm_next) {
if (check_vma(vma)) {
- struct file_probes *file_p = proc_p_find_file_p(proc_p, vma);
+ struct file_probes *file_p = proc_p_find_file_p(procs, vma);
if (file_p) {
if (!file_p->loaded) {
- set_mapping_file(file_p, proc_p, task, vma);
+ set_mapping_file(file_p, procs, task, vma);
file_p->loaded = 1;
}
return err;
}
-static int uninstall_us_proc_probes(struct task_struct *task, struct proc_probes *proc_p, enum US_FLAGS flag)
+static int uninstall_us_proc_probes(struct task_struct *task, struct sspt_procs *procs, enum US_FLAGS flag)
{
int err;
struct file_probes *file_p;
- list_for_each_entry_rcu(file_p, &proc_p->file_list, list) {
+ list_for_each_entry_rcu(file_p, &procs->file_list, list) {
err = unregister_us_file_probes(task, file_p, flag);
if (err != 0) {
// TODO:
struct task_struct *task = current->group_leader;
struct mm_struct *mm = task->mm;
struct vm_area_struct *vma = 0;
- struct proc_probes *proc_p = NULL;
+ struct sspt_procs *procs = NULL;
/*
* Because process threads have same address space
* we instrument only group_leader of all this threads
}
if (is_libonly()) {
- proc_p = get_proc_probes_by_task_or_new(task);
+ procs = get_proc_probes_by_task_or_new(task);
} else {
// find task
if (us_proc_info.tgid == 0) {
}
if (us_proc_info.tgid == task->tgid) {
- proc_p = us_proc_info.pp;
+ procs = us_proc_info.pp;
}
}
- if (proc_p) {
+ if (procs) {
unsigned long page = addr & PAGE_MASK;
#ifdef __ANDROID
// overhead
do_gettimeofday(&imi_tv1);
- install_page_probes(page, task, proc_p, 1);
+ install_page_probes(page, task, procs, 1);
do_gettimeofday(&imi_tv2);
imi_sum_hit++;
imi_sum_time += ((imi_tv2.tv_sec - imi_tv1.tv_sec) * USEC_IN_SEC_NUM +
printk("### print_vma: END\n");
}
-static int remove_unmap_probes(struct task_struct *task, struct proc_probes *proc_p, unsigned long start, size_t len)
+static int remove_unmap_probes(struct task_struct *task, struct sspt_procs *procs, unsigned long start, size_t len)
{
struct mm_struct *mm = task->mm;
struct vm_area_struct *vma;
struct file_probes *file_p;
unsigned long end = start + len;
- file_p = proc_p_find_file_p(proc_p, vma);
+ file_p = proc_p_find_file_p(procs, vma);
if (file_p) {
if (vma->vm_start == start || vma->vm_end == end) {
unregister_us_file_probes(task, file_p, US_NOT_RP2);
void do_munmap_probe_pre_code(struct mm_struct *mm, unsigned long start, size_t len)
{
- struct proc_probes *proc_p = NULL;
+ struct sspt_procs *procs = NULL;
struct task_struct *task = current;
//if user-space instrumentation is not set
}
if (is_libonly()) {
- proc_p = get_proc_probes_by_task(task);
+ procs = get_proc_probes_by_task(task);
} else {
if (task->tgid == us_proc_info.tgid) {
- proc_p = us_proc_info.pp;
+ procs = us_proc_info.pp;
}
}
- if (proc_p) {
- if (remove_unmap_probes(task, proc_p, start, len)) {
+ if (procs) {
+ if (remove_unmap_probes(task, procs, start, len)) {
printk("ERROR do_munmap: start=%x, len=%x\n", start, len);
}
}
void mm_release_probe_pre_code(void)
{
struct task_struct *task = current;
- struct proc_probes *proc_p = NULL;
+ struct sspt_procs *procs = NULL;
if (!is_us_instrumentation() || task->tgid != task->pid) {
return;
}
if (is_libonly()) {
- proc_p = get_proc_probes_by_task(task);
+ procs = get_proc_probes_by_task(task);
} else {
if (task->tgid == us_proc_info.tgid) {
- proc_p = get_proc_probes_by_task(task);
+ procs = get_proc_probes_by_task(task);
us_proc_info.tgid = 0;
}
}
- if (proc_p) {
- int ret = uninstall_us_proc_probes(task, proc_p, US_NOT_RP2);
+ if (procs) {
+ int ret = uninstall_us_proc_probes(task, procs, US_NOT_RP2);
if (ret != 0) {
EPRINTF ("failed to uninstall IPs (%d)!", ret);
}
EXPORT_SYMBOL_GPL(mm_release_probe_pre_code);
-static void recover_child(struct task_struct *child_task, struct proc_probes *proc_p)
+static void recover_child(struct task_struct *child_task, struct sspt_procs *procs)
{
- uninstall_us_proc_probes(child_task, proc_p, US_DISARM);
+ uninstall_us_proc_probes(child_task, procs, US_DISARM);
}
static void rm_uprobes_child(struct task_struct *new_task)
{
if (is_libonly()) {
- struct proc_probes *proc_p = get_proc_probes_by_task(current);
- if(proc_p) {
- recover_child(new_task, proc_p);
+ struct sspt_procs *procs = get_proc_probes_by_task(current);
+ if(procs) {
+ recover_child(new_task, procs);
}
} else {
if(us_proc_info.tgid == current->tgid) {