From 40a2aba7fdbcefea0a841bc24f32714168e9ea7e Mon Sep 17 00:00:00 2001 From: Anatolii Nikulin Date: Fri, 24 Jul 2015 11:08:51 +0300 Subject: [PATCH] [REFACTOR] Change probe info implementation Change-Id: I5731ba88680de367f045b6072edf34ccaf41272c Signed-off-by: Anatolii Nikulin --- fbiprobe/fbiprobe.c | 6 +- nsp/nsp.c | 30 ++++----- parser/msg_parser.c | 78 +++++++++++----------- parser/msg_parser.h | 2 +- parser/us_inst.c | 2 +- preload/preload_control.c | 2 +- preload/preload_module.c | 8 +-- preload/preload_probe.c | 8 +-- retprobe/retprobe.c | 6 +- uprobe/swap_uprobes.c | 2 - us_manager/img/img_file.c | 4 +- us_manager/img/img_file.h | 4 +- us_manager/img/img_ip.c | 42 ++++++------ us_manager/img/img_ip.h | 5 +- us_manager/img/img_proc.c | 8 +-- us_manager/img/img_proc.h | 4 +- us_manager/pf/pf_group.c | 4 +- us_manager/pf/pf_group.h | 4 +- us_manager/probes/probe_info_new.c | 67 +++++-------------- us_manager/probes/probe_info_new.h | 7 +- us_manager/probes/probes.c | 129 ++++++------------------------------- us_manager/probes/probes.h | 33 ++++++---- us_manager/probes/use_probes.h | 10 +-- us_manager/sspt/ip.c | 38 ++++------- us_manager/sspt/ip.h | 7 +- us_manager/sspt/sspt.h | 16 ++--- us_manager/sspt/sspt_debug.h | 2 +- us_manager/sspt/sspt_file.c | 18 ++++-- us_manager/sspt/sspt_file.h | 3 +- us_manager/sspt/sspt_page.c | 2 +- us_manager/sspt/sspt_proc.c | 29 --------- us_manager/sspt/sspt_proc.h | 3 - webprobe/webprobe.c | 2 +- webprobe/webprobe_prof.c | 6 +- wsp/wsp.c | 20 +++--- 35 files changed, 229 insertions(+), 382 deletions(-) diff --git a/fbiprobe/fbiprobe.c b/fbiprobe/fbiprobe.c index 96c2467..bf8681e 100644 --- a/fbiprobe/fbiprobe.c +++ b/fbiprobe/fbiprobe.c @@ -258,11 +258,11 @@ exit: static int fbi_probe_handler(struct uprobe *p, struct pt_regs *regs) { struct us_ip *ip = container_of(p, struct us_ip, uprobe); - struct fbi_info *fbi_i = &ip->info->fbi_i; + struct fbi_info *fbi_i = &ip->desc->info.fbi_i; struct fbi_var_data *fbi_d = NULL; uint8_t i; - if (ip->info->probe_type != SWAP_FBIPROBE) { + if (ip->desc->type != SWAP_FBIPROBE) { /* How this can occure? Doesn't matter, just print and go */ print_err("Not FBI probe in FBI handler!\n"); return 0; @@ -313,7 +313,7 @@ void fbi_probe_init(struct us_ip *ip) void fbi_probe_uninit(struct us_ip *ip) { if (ip != NULL) - fbi_probe_cleanup(ip->info); + fbi_probe_cleanup(&ip->desc->info); } static int fbi_probe_register_probe(struct us_ip *ip) diff --git a/nsp/nsp.c b/nsp/nsp.c index 07482fa..8c10cd9 100644 --- a/nsp/nsp.c +++ b/nsp/nsp.c @@ -41,51 +41,51 @@ /* dlopen@plt */ static int dlopen_eh(struct uretprobe_instance *ri, struct pt_regs *regs); static int dlopen_rh(struct uretprobe_instance *ri, struct pt_regs *regs); -static struct probe_info_new pin_dlopen = MAKE_URPROBE(dlopen_eh, dlopen_rh, 0); +static struct probe_desc pin_dlopen = MAKE_URPROBE(dlopen_eh, dlopen_rh, 0); static struct probe_new p_dlopen = { - .info = &pin_dlopen + .desc = &pin_dlopen }; /* dlsym@plt */ static int dlsym_eh(struct uretprobe_instance *ri, struct pt_regs *regs); static int dlsym_rh(struct uretprobe_instance *ri, struct pt_regs *regs); -static struct probe_info_new pin_dlsym = MAKE_URPROBE(dlsym_eh, dlsym_rh, 0); +static struct probe_desc pin_dlsym = MAKE_URPROBE(dlsym_eh, dlsym_rh, 0); static struct probe_new p_dlsym = { - .info = &pin_dlsym + .desc = &pin_dlsym }; /* main */ static int main_eh(struct uretprobe_instance *ri, struct pt_regs *regs); static int main_rh(struct uretprobe_instance *ri, struct pt_regs *regs); -static struct probe_info_new pin_main = MAKE_URPROBE(main_eh, main_rh, 0); +static struct probe_desc pin_main = MAKE_URPROBE(main_eh, main_rh, 0); /* appcore_efl_main */ static int ac_efl_main_h(struct uprobe *p, struct pt_regs *regs); -static struct probe_info_new pin_ac_efl_main = MAKE_UPROBE(ac_efl_main_h); +static struct probe_desc pin_ac_efl_main = MAKE_UPROBE(ac_efl_main_h); static struct probe_new p_ac_efl_main = { - .info = &pin_ac_efl_main + .desc = &pin_ac_efl_main }; /* appcore_init@plt */ static int ac_init_rh(struct uretprobe_instance *ri, struct pt_regs *regs); -static struct probe_info_new pin_ac_init = MAKE_URPROBE(NULL, ac_init_rh, 0); +static struct probe_desc pin_ac_init = MAKE_URPROBE(NULL, ac_init_rh, 0); static struct probe_new p_ac_init = { - .info = &pin_ac_init + .desc = &pin_ac_init }; /* elm_run@plt */ static int elm_run_h(struct uprobe *p, struct pt_regs *regs); -static struct probe_info_new pin_elm_run = MAKE_UPROBE(elm_run_h); +static struct probe_desc pin_elm_run = MAKE_UPROBE(elm_run_h); static struct probe_new p_elm_run = { - .info = &pin_elm_run + .desc = &pin_elm_run }; /* __do_app */ static int do_app_eh(struct uretprobe_instance *ri, struct pt_regs *regs); static int do_app_rh(struct uretprobe_instance *ri, struct pt_regs *regs); -static struct probe_info_new pin_do_app = MAKE_URPROBE(do_app_eh, do_app_rh, 0); +static struct probe_desc pin_do_app = MAKE_URPROBE(do_app_eh, do_app_rh, 0); static struct probe_new p_do_app = { - .info = &pin_do_app + .desc = &pin_do_app }; @@ -216,7 +216,7 @@ static struct nsp_data *nsp_data_create(const char *app_path, } data->app_dentry = dentry; - data->p_main.info = &pin_main; + data->p_main.desc = &pin_main; data->p_main.offset = main_addr; data->pfg = NULL; @@ -736,7 +736,7 @@ static int main_rh(struct uretprobe_instance *ri, struct pt_regs *regs) ip = container_of(rp, struct us_ip, retprobe); func_addr = (unsigned long)ip->orig_addr; ret_addr = (unsigned long)ri->ret_addr; - ret_type = ip->info->rp_i.ret_type; + ret_type = ip->desc->info.rp_i.ret_type; rp_msg_exit(regs, func_addr, 'n', ret_addr); } diff --git a/parser/msg_parser.c b/parser/msg_parser.c index 42b8b0d..9af49a5 100644 --- a/parser/msg_parser.c +++ b/parser/msg_parser.c @@ -276,7 +276,7 @@ void restore_config(struct conf_data *conf) * @param pi Pointer to the probe_info struct. * @return 0 on success, error code on error. */ -int get_retprobe(struct msg_buf *mb, struct probe_info *pi) +int get_retprobe(struct msg_buf *mb, struct probe_desc *pd) { char *args; char ret_type; @@ -293,10 +293,9 @@ int get_retprobe(struct msg_buf *mb, struct probe_info *pi) goto free_args; } - pi->probe_type = SWAP_RETPROBE; - pi->size = 0; - pi->rp_i.args = args; - pi->rp_i.ret_type = ret_type; + pd->type = SWAP_RETPROBE; + pd->info.rp_i.args = args; + pd->info.rp_i.ret_type = ret_type; return 0; @@ -312,10 +311,9 @@ free_args: * @param pi Pointer to the probe_info struct. * @return 0 on success, error code on error. */ -int get_webprobe(struct msg_buf *mb, struct probe_info *pi) +int get_webprobe(struct msg_buf *mb, struct probe_desc *pd) { - pi->probe_type = SWAP_WEBPROBE; - pi->size = 0; + pd->type = SWAP_WEBPROBE; return 0; } @@ -338,7 +336,7 @@ void put_retprobe(struct probe_info *pi) * @param pi Pointer to the probe_info struct. * @return 0 on success, error code on error. */ -int get_preload_probe(struct msg_buf *mb, struct probe_info *pi) +int get_preload_probe(struct msg_buf *mb, struct probe_desc *pd) { u64 handler; u8 flags; @@ -355,10 +353,9 @@ int get_preload_probe(struct msg_buf *mb, struct probe_info *pi) return -EINVAL; } - pi->probe_type = SWAP_PRELOAD_PROBE; - pi->size = sizeof(pi->pl_i) + sizeof(pi->probe_type) + sizeof(pi->size); - pi->pl_i.handler = handler; - pi->pl_i.flags = flags; + pd->type = SWAP_PRELOAD_PROBE; + pd->info.pl_i.handler = handler; + pd->info.pl_i.flags = flags; return 0; } @@ -381,10 +378,9 @@ void put_preload_probe(struct probe_info *pi) * @return 0 on success, error code on error. */ -int get_get_caller_probe(struct msg_buf *mb, struct probe_info *pi) +int get_get_caller_probe(struct msg_buf *mb, struct probe_desc *pd) { - pi->probe_type = SWAP_GET_CALLER; - pi->size = sizeof(pi->gc_i); + pd->type = SWAP_GET_CALLER; return 0; } @@ -406,10 +402,9 @@ void put_get_caller_probe(struct probe_info *pi) * @param pi Pointer to the probe_info struct. * @return 0 on success, error code on error. */ -int get_get_call_type_probe(struct msg_buf *mb, struct probe_info *pi) +int get_get_call_type_probe(struct msg_buf *mb, struct probe_desc *pd) { - pi->probe_type = SWAP_GET_CALL_TYPE; - pi->size = sizeof(pi->gct_i); + pd->type = SWAP_GET_CALL_TYPE; return 0; } @@ -431,10 +426,9 @@ void put_get_call_type_probe(struct probe_info *pi) * @param pi Pointer to the probe_info struct. * @return 0 on success, error code on error. */ -int get_write_msg_probe(struct msg_buf *mb, struct probe_info *pi) +int get_write_msg_probe(struct msg_buf *mb, struct probe_desc *pd) { - pi->probe_type = SWAP_WRITE_MSG; - pi->size = sizeof(pi->wm_i); + pd->type = SWAP_WRITE_MSG; return 0; } @@ -536,7 +530,7 @@ free_steps: return -EINVAL; } -int get_fbi_probe(struct msg_buf *mb, struct probe_info *pi) +int get_fbi_probe(struct msg_buf *mb, struct probe_desc *pd) { uint8_t var_count, i; struct fbi_var_data *vars; @@ -558,10 +552,9 @@ int get_fbi_probe(struct msg_buf *mb, struct probe_info *pi) goto free_vars; } - pi->probe_type = SWAP_FBIPROBE; - pi->fbi_i.var_count = var_count; - pi->fbi_i.vars = vars; - pi->size =0 ; + pd->type = SWAP_FBIPROBE; + pd->info.fbi_i.var_count = var_count; + pd->info.fbi_i.vars = vars; return 0; free_vars: @@ -624,31 +617,31 @@ struct func_inst_data *create_func_inst_data(struct msg_buf *mb) switch (type) { case SWAP_RETPROBE: - if (get_retprobe(mb, &(fi->probe_i)) != 0) + if (get_retprobe(mb, &fi->p_desc) != 0) goto free_func_inst; break; case SWAP_WEBPROBE: - if (get_webprobe(mb, &(fi->probe_i)) != 0) + if (get_webprobe(mb, &fi->p_desc) != 0) goto free_func_inst; break; case SWAP_PRELOAD_PROBE: - if (get_preload_probe(mb, &(fi->probe_i)) != 0) + if (get_preload_probe(mb, &fi->p_desc) != 0) goto free_func_inst; break; case SWAP_GET_CALLER: - if (get_get_caller_probe(mb, &(fi->probe_i)) != 0) + if (get_get_caller_probe(mb, &fi->p_desc) != 0) goto free_func_inst; break; case SWAP_GET_CALL_TYPE: - if (get_get_call_type_probe(mb, &(fi->probe_i)) != 0) + if (get_get_call_type_probe(mb, &fi->p_desc) != 0) goto free_func_inst; break; case SWAP_FBIPROBE: - if (get_fbi_probe(mb, &(fi->probe_i)) != 0) + if (get_fbi_probe(mb, &fi->p_desc) != 0) goto free_func_inst; break; case SWAP_WRITE_MSG: - if (get_write_msg_probe(mb, &(fi->probe_i)) != 0) + if (get_write_msg_probe(mb, &fi->p_desc) != 0) goto free_func_inst; break; default: @@ -657,6 +650,7 @@ struct func_inst_data *create_func_inst_data(struct msg_buf *mb) goto free_func_inst; } + fi->p_desc.type = type; return fi; free_func_inst: @@ -673,30 +667,30 @@ free_func_inst: */ void destroy_func_inst_data(struct func_inst_data *fi) { - switch (fi->probe_i.probe_type) { + switch (fi->p_desc.type) { case SWAP_RETPROBE: - put_retprobe(&(fi->probe_i)); + put_retprobe(&(fi->p_desc.info)); break; case SWAP_WEBPROBE: break; case SWAP_PRELOAD_PROBE: - put_preload_probe(&(fi->probe_i)); + put_preload_probe(&(fi->p_desc.info)); break; case SWAP_GET_CALLER: - put_get_caller_probe(&(fi->probe_i)); + put_get_caller_probe(&(fi->p_desc.info)); break; case SWAP_GET_CALL_TYPE: - put_get_call_type_probe(&(fi->probe_i)); + put_get_call_type_probe(&(fi->p_desc.info)); break; case SWAP_FBIPROBE: - put_fbi_probe(&(fi->probe_i)); + put_fbi_probe(&(fi->p_desc.info)); break; case SWAP_WRITE_MSG: - put_write_msg_probe(&(fi->probe_i)); + put_write_msg_probe(&(fi->p_desc.info)); break; default: printk(KERN_WARNING "SWAP PARSER: Wrong probe type %d!\n", - fi->probe_i.probe_type); + fi->p_desc.type); } kfree(fi); diff --git a/parser/msg_parser.h b/parser/msg_parser.h index 2358f53..ec76a26 100644 --- a/parser/msg_parser.h +++ b/parser/msg_parser.h @@ -83,7 +83,7 @@ struct conf_data { */ struct func_inst_data { u64 addr; /**< Function address. */ - struct probe_info probe_i; /**< Probe info. */ + struct probe_desc p_desc; /**< Probe info. */ }; /** diff --git a/parser/us_inst.c b/parser/us_inst.c index 17c699b..648f3bf 100644 --- a/parser/us_inst.c +++ b/parser/us_inst.c @@ -148,7 +148,7 @@ static int mod_func_inst(struct func_inst_data *func, struct pf_group *pfg, switch (mt) { case MT_ADD: ret = pf_register_probe(pfg, dentry, func->addr, - &func->probe_i); + &func->p_desc); break; case MT_DEL: ret = pf_unregister_probe(pfg, dentry, func->addr); diff --git a/preload/preload_control.c b/preload/preload_control.c index 93bdfd3..37cff11 100644 --- a/preload/preload_control.c +++ b/preload/preload_control.c @@ -216,7 +216,7 @@ enum preload_call_type preload_control_call_type(struct us_ip *ip, void *caller) if (__is_instrumented(caller)) return INTERNAL_CALL; - if (ip->info->pl_i.flags & SWAP_PRELOAD_ALWAYS_RUN) + if (ip->desc->info.pl_i.flags & SWAP_PRELOAD_ALWAYS_RUN) return EXTERNAL_CALL; return NOT_INSTRUMENTED; diff --git a/preload/preload_module.c b/preload/preload_module.c index f7cb11e..f73cd7b 100644 --- a/preload/preload_module.c +++ b/preload/preload_module.c @@ -292,7 +292,7 @@ static inline struct vm_area_struct *__get_vma_by_addr(struct task_struct *task, static inline bool __inverted(struct us_ip *ip) { - unsigned long flags = ip->info->pl_i.flags; + unsigned long flags = ip->desc->info.pl_i.flags; if (flags & SWAP_PRELOAD_INVERTED_PROBE) return true; @@ -321,7 +321,7 @@ static inline bool __check_flag_and_call_type(struct us_ip *ip, static inline bool __is_probe_non_block(struct us_ip *ip) { - if (ip->info->pl_i.flags & SWAP_PRELOAD_NON_BLOCK_PROBE) + if (ip->desc->info.pl_i.flags & SWAP_PRELOAD_NON_BLOCK_PROBE) return true; return false; @@ -566,7 +566,7 @@ static int preload_us_entry(struct uretprobe_instance *ri, struct pt_regs *regs) struct us_ip *ip = container_of(ri->rp, struct us_ip, retprobe); struct us_priv *priv = (struct us_priv *)ri->data; unsigned long flags = get_preload_flags(current); - unsigned long offset = ip->info->pl_i.handler; + unsigned long offset = ip->desc->info.pl_i.handler; unsigned long vaddr = 0; char __user *path = NULL; @@ -653,7 +653,7 @@ static int preload_us_ret(struct uretprobe_instance *ri, struct pt_regs *regs) struct us_ip *ip = container_of(ri->rp, struct us_ip, retprobe); struct us_priv *priv = (struct us_priv *)ri->data; unsigned long flags = get_preload_flags(current); - unsigned long offset = ip->info->pl_i.handler; + unsigned long offset = ip->desc->info.pl_i.handler; unsigned long vaddr = 0; switch (preload_pd_get_state(pd)) { diff --git a/preload/preload_probe.c b/preload/preload_probe.c index 9ca7317..52552d8 100644 --- a/preload/preload_probe.c +++ b/preload/preload_probe.c @@ -127,7 +127,7 @@ static void preload_uninit(struct us_ip *ip) { preload_module_uprobe_exit(ip); - preload_info_cleanup(ip->info); + preload_info_cleanup(&ip->desc->info); } static struct probe_iface preload_iface = { @@ -176,7 +176,7 @@ static void get_caller_uninit(struct us_ip *ip) { preload_module_get_caller_exit(ip); - get_caller_info_cleanup(ip->info); + get_caller_info_cleanup(&ip->desc->info); } static struct probe_iface get_caller_iface = { @@ -198,7 +198,7 @@ static void get_call_type_uninit(struct us_ip *ip) { preload_module_get_call_type_exit(ip); - get_caller_info_cleanup(ip->info); + get_caller_info_cleanup(&ip->desc->info); } static struct probe_iface get_call_type_iface = { @@ -220,7 +220,7 @@ static void write_msg_uninit(struct us_ip *ip) { preload_module_write_msg_exit(ip); - get_caller_info_cleanup(ip->info); + get_caller_info_cleanup(&ip->desc->info); } static struct probe_iface write_msg_iface = { diff --git a/retprobe/retprobe.c b/retprobe/retprobe.c index 8a5daa2..0128253 100644 --- a/retprobe/retprobe.c +++ b/retprobe/retprobe.c @@ -78,7 +78,7 @@ static int retprobe_entry_handler(struct uretprobe_instance *ri, struct pt_regs if (rp && get_quiet() == QT_OFF) { struct us_ip *ip = container_of(rp, struct us_ip, retprobe); - const char *fmt = ip->info->rp_i.args; + const char *fmt = ip->desc->info.rp_i.args; const unsigned long func_addr = (unsigned long)ip->orig_addr; rp_msg_entry(regs, func_addr, fmt); @@ -95,7 +95,7 @@ static int retprobe_ret_handler(struct uretprobe_instance *ri, struct pt_regs *r struct us_ip *ip = container_of(rp, struct us_ip, retprobe); const unsigned long func_addr = (unsigned long)ip->orig_addr; const unsigned long ret_addr = (unsigned long)ri->ret_addr; - const char ret_type = ip->info->rp_i.ret_type; + const char ret_type = ip->desc->info.rp_i.ret_type; rp_msg_exit(regs, func_addr, ret_type, ret_addr); } @@ -112,7 +112,7 @@ static void retprobe_init(struct us_ip *ip) static void retprobe_uninit(struct us_ip *ip) { - retprobe_cleanup(ip->info); + retprobe_cleanup(&ip->desc->info); } diff --git a/uprobe/swap_uprobes.c b/uprobe/swap_uprobes.c index 699ffa1..e5a43a4 100644 --- a/uprobe/swap_uprobes.c +++ b/uprobe/swap_uprobes.c @@ -484,8 +484,6 @@ int swap_register_uprobe(struct uprobe *p) if (!p->addr) return -EINVAL; - DBPRINTF("p->addr = 0x%p p = 0x%p\n", p->addr, p); - /* thumb address = address-1; */ #if defined(CONFIG_ARM) /* TODO: must be corrected in 'bundle' */ diff --git a/us_manager/img/img_file.c b/us_manager/img/img_file.c index e7bd763..07b1ba4 100644 --- a/us_manager/img/img_file.c +++ b/us_manager/img/img_file.c @@ -99,7 +99,7 @@ static struct img_ip *find_img_ip(struct img_file *file, unsigned long addr) * @return Error code */ int img_file_add_ip(struct img_file *file, unsigned long addr, - struct probe_info *probe_i) + struct probe_desc *pd) { struct img_ip *ip; @@ -109,7 +109,7 @@ int img_file_add_ip(struct img_file *file, unsigned long addr, return 0; } - ip = create_img_ip(addr, probe_i); + ip = create_img_ip(addr, pd); img_add_ip_by_list(file, ip); return 0; diff --git a/us_manager/img/img_file.h b/us_manager/img/img_file.h index 5e7977b..081a1ba 100644 --- a/us_manager/img/img_file.h +++ b/us_manager/img/img_file.h @@ -28,7 +28,7 @@ #include -struct probe_info; +struct probe_desc; /** * @struct img_file @@ -44,7 +44,7 @@ struct img_file *create_img_file(struct dentry *dentry); void free_img_file(struct img_file *ip); int img_file_add_ip(struct img_file *file, unsigned long addr, - struct probe_info *probe_i); + struct probe_desc *pd); int img_file_del_ip(struct img_file *file, unsigned long addr); int img_file_empty(struct img_file *file); diff --git a/us_manager/img/img_ip.c b/us_manager/img/img_ip.c index ef0d0fe..d03b09c 100644 --- a/us_manager/img/img_ip.c +++ b/us_manager/img/img_ip.c @@ -25,6 +25,7 @@ #include "img_ip.h" #include +#include #include /** @@ -34,26 +35,21 @@ * @param probe_i Pointer to the probe info data. * @return Pointer to the created img_ip struct */ -struct img_ip *create_img_ip(unsigned long addr, struct probe_info *info) +struct img_ip *create_img_ip(unsigned long addr, struct probe_desc *pd) { struct img_ip *ip; ip = kmalloc(sizeof(*ip), GFP_KERNEL); - if (ip) { - struct probe_info *info_new; + if (!ip) + return NULL; - info_new = probe_info_dup(info); - if (info_new == NULL) { - kfree(ip); - return NULL; - } - - probe_info_copy(info, info_new); - - INIT_LIST_HEAD(&ip->list); - ip->addr = addr; - ip->info = info_new; - } + INIT_LIST_HEAD(&ip->list); + INIT_LIST_HEAD(&ip->ihead); + ip->addr = addr; + /* TODO replace struct probe_desc in img_ip + * with pointer on struct probe_desc + */ + memcpy(&ip->desc, pd, sizeof(struct probe_desc)); return ip; } @@ -66,8 +62,16 @@ struct img_ip *create_img_ip(unsigned long addr, struct probe_info *info) */ void free_img_ip(struct img_ip *ip) { - probe_info_cleanup(ip->info); - probe_info_free(ip->info); + struct us_ip *p, *n; + + list_for_each_entry_safe(p, n, &ip->ihead, img_list) { + list_del_init(&p->img_list); + p->iip = NULL; + list_del(&p->list); + probe_info_unregister(p->desc->type, p, 1); + free_ip(p); + } + kfree(ip); } @@ -81,8 +85,8 @@ void free_img_ip(struct img_ip *ip) /* debug */ void img_ip_print(struct img_ip *ip) { - if (ip->info->probe_type == SWAP_RETPROBE) + if (ip->desc.type == SWAP_RETPROBE) printk(KERN_INFO "### addr=8%lx, args=%s\n", - ip->addr, ip->info->rp_i.args); + ip->addr, ip->desc.info.rp_i.args); } /* debug */ diff --git a/us_manager/img/img_ip.h b/us_manager/img/img_ip.h index 08a7b3b..115cdc1 100644 --- a/us_manager/img/img_ip.h +++ b/us_manager/img/img_ip.h @@ -36,10 +36,11 @@ struct img_ip { struct list_head list; /**< For img_file */ unsigned long addr; /**< Function address */ - struct probe_info *info; /**< Probe info */ + struct list_head ihead; /**< List head for sspt ip */ + struct probe_desc desc; /**< Probe info */ }; -struct img_ip *create_img_ip(unsigned long addr, struct probe_info *info); +struct img_ip *create_img_ip(unsigned long addr, struct probe_desc *info); void free_img_ip(struct img_ip *ip); /* debug */ diff --git a/us_manager/img/img_proc.c b/us_manager/img/img_proc.c index 2029c2e..6e5a95e 100644 --- a/us_manager/img/img_proc.c +++ b/us_manager/img/img_proc.c @@ -113,7 +113,7 @@ static struct img_file *find_img_file(struct img_proc *proc, * @return Error code */ int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry, - unsigned long addr, struct probe_info *probe_i) + unsigned long addr, struct probe_desc *pd) { int ret; struct img_file *file; @@ -121,7 +121,7 @@ int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry, write_lock(&proc->rwlock); file = find_img_file(proc, dentry); if (file) { - ret = img_file_add_ip(file, addr, probe_i); + ret = img_file_add_ip(file, addr, pd); goto unlock; } @@ -131,7 +131,7 @@ int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry, goto unlock; } - ret = img_file_add_ip(file, addr, probe_i); + ret = img_file_add_ip(file, addr, pd); if (ret) { printk(KERN_INFO "Cannot add ip to img file\n"); free_img_file(file); @@ -188,7 +188,7 @@ void img_proc_copy_to_sspt(struct img_proc *i_proc, struct sspt_proc *proc) file = sspt_proc_find_file_or_new(proc, i_file->dentry); list_for_each_entry(i_ip, &i_file->ip_list, list) - sspt_file_add_ip(file, i_ip->addr, i_ip->info); + sspt_file_add_ip(file, i_ip); } read_unlock(&i_proc->rwlock); } diff --git a/us_manager/img/img_proc.h b/us_manager/img/img_proc.h index 8bdc67d..713bcf0 100644 --- a/us_manager/img/img_proc.h +++ b/us_manager/img/img_proc.h @@ -29,14 +29,14 @@ struct dentry; struct sspt_proc; -struct probe_info; +struct probe_desc; struct img_proc *create_img_proc(void); void free_img_proc(struct img_proc *proc); int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry, - unsigned long addr, struct probe_info *probe_i); + unsigned long addr, struct probe_desc *pd); int img_proc_del_ip(struct img_proc *proc, struct dentry *dentry, unsigned long addr); diff --git a/us_manager/pf/pf_group.c b/us_manager/pf/pf_group.c index f544728..b251bd7 100644 --- a/us_manager/pf/pf_group.c +++ b/us_manager/pf/pf_group.c @@ -406,9 +406,9 @@ EXPORT_SYMBOL_GPL(put_pf_group); * @return Error code */ int pf_register_probe(struct pf_group *pfg, struct dentry *dentry, - unsigned long offset, struct probe_info *probe_i) + unsigned long offset, struct probe_desc *pd) { - return img_proc_add_ip(pfg->i_proc, dentry, offset, probe_i); + return img_proc_add_ip(pfg->i_proc, dentry, offset, pd); } EXPORT_SYMBOL_GPL(pf_register_probe); diff --git a/us_manager/pf/pf_group.h b/us_manager/pf/pf_group.h index 00f71c1..5c61567 100644 --- a/us_manager/pf/pf_group.h +++ b/us_manager/pf/pf_group.h @@ -30,7 +30,7 @@ struct dentry; struct pf_group; struct sspt_proc; -struct probe_info; +struct probe_desc; struct pfg_msg_cb { @@ -56,7 +56,7 @@ void pfg_msg_cb_reset(struct pf_group *pfg); struct pfg_msg_cb *pfg_msg_cb_get(struct pf_group *pfg); int pf_register_probe(struct pf_group *pfg, struct dentry *dentry, - unsigned long offset, struct probe_info *probe_i); + unsigned long offset, struct probe_desc *pd); int pf_unregister_probe(struct pf_group *pfg, struct dentry *dentry, unsigned long offset); diff --git a/us_manager/probes/probe_info_new.c b/us_manager/probes/probe_info_new.c index 22c49b0..fbeb4be 100644 --- a/us_manager/probes/probe_info_new.c +++ b/us_manager/probes/probe_info_new.c @@ -38,11 +38,11 @@ static int urp_entry_handler(struct uretprobe_instance *ri, struct pt_regs *regs if (rp) { struct us_ip *ip = container_of(rp, struct us_ip, retprobe); - struct probe_info_new *info_new; + struct probe_desc *pd = NULL; - info_new = probe_info_get_val(ip->info, struct probe_info_new *); - if (info_new->u.rp.entry_handler) - return info_new->u.rp.entry_handler(ri, regs); + pd = ip->desc; + if (pd && pd->u.rp.entry_handler) + return pd->u.rp.entry_handler(ri, regs); } @@ -55,11 +55,11 @@ static int urp_ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs) if (rp) { struct us_ip *ip = container_of(rp, struct us_ip, retprobe); - struct probe_info_new *info_new; + struct probe_desc *pd = NULL; - info_new = probe_info_get_val(ip->info, struct probe_info_new *); - if (info_new->u.rp.ret_handler) - return info_new->u.rp.ret_handler(ri, regs); + pd = ip->desc; + if (pd && pd->u.rp.ret_handler) + return pd->u.rp.ret_handler(ri, regs); } return 0; @@ -68,36 +68,15 @@ static int urp_ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs) static int uprobe_handler(struct uprobe *p, struct pt_regs *regs) { struct us_ip *ip = container_of(p, struct us_ip, uprobe); - struct probe_info_new *info_new; + struct probe_desc *pd = NULL; - info_new = probe_info_get_val(ip->info, struct probe_info_new *); - if (info_new->u.p.handler) - return info_new->u.p.handler(p, regs); + pd = ip->desc; + if (pd && pd->u.p.handler) + return pd->u.p.handler(p, regs); return 0; } - - - -void pin_set_probe(struct probe_info_otg *otg, unsigned long vaddr) -{ - struct sspt_proc *proc; - struct task_struct *task = current; - - otg->info.probe_type = otg->data->type; - otg->info.size = sizeof(struct probe_info_new *); - - proc = sspt_proc_get_by_task(task); - if (proc) { - sspt_proc_install_probe(proc, vaddr, &otg->info); - } else { - pr_err("task[%u %u %s] not in sspt\n", - task->tgid, task->pid, task->comm); - } -} -EXPORT_SYMBOL_GPL(pin_set_probe); - /* * register/unregister interface */ @@ -105,23 +84,13 @@ int pin_register(struct probe_new *probe, struct pf_group *pfg, struct dentry *dentry) { int ret; - struct probe_info *info; - struct probe_info_new *info_new = probe->info; - - info = probe_info_create(struct probe_info_new *, info_new->type); - if (info == NULL) - return -ENOMEM; - - probe_info_set_val(info, struct probe_info_new *, info_new); - - ret = pf_register_probe(pfg, dentry, probe->offset, info); + ret = pf_register_probe(pfg, dentry, probe->offset, probe->desc); if (ret) { - probe_info_free(info); + printk(KERN_ERR "%s: register probe failed (%d)\n", + __FUNCTION__, ret); return ret; } - info_new->info = info; - return 0; } EXPORT_SYMBOL_GPL(pin_register); @@ -130,16 +99,14 @@ int pin_unregister(struct probe_new *probe, struct pf_group *pfg, struct dentry *dentry) { int ret; - struct probe_info_new *info_new = probe->info; ret = pf_unregister_probe(pfg, dentry, probe->offset); if (ret) { - /* error */ + printk(KERN_ERR "%s: unregister probe failed (%d)\n", + __FUNCTION__, ret); return ret; } - probe_info_free(info_new->info); - return 0; } EXPORT_SYMBOL_GPL(pin_unregister); diff --git a/us_manager/probes/probe_info_new.h b/us_manager/probes/probe_info_new.h index b176522..8df6947 100644 --- a/us_manager/probes/probe_info_new.h +++ b/us_manager/probes/probe_info_new.h @@ -51,13 +51,12 @@ struct probe_info_new { } u; /* private */ - struct probe_info *info; + struct probe_info info; }; - struct probe_new { unsigned long offset; - struct probe_info_new *info; + struct probe_desc *desc; }; @@ -80,8 +79,6 @@ struct probe_info_otg { struct probe_info_new *data; /* field 'data[0]' in probe_info struct */ }; -void pin_set_probe(struct probe_info_otg *otg, unsigned long vaddr); - int pin_register(struct probe_new *probe, struct pf_group *pfg, struct dentry *dentry); int pin_unregister(struct probe_new *probe, struct pf_group *pfg, diff --git a/us_manager/probes/probes.c b/us_manager/probes/probes.c index e38789f..3d1aef7 100644 --- a/us_manager/probes/probes.c +++ b/us_manager/probes/probes.c @@ -31,41 +31,6 @@ #include #include - -struct probe_info *probe_info_malloc(size_t size, enum probe_t type) -{ - struct probe_info *info; - - info = kmalloc(sizeof(*info) + size, GFP_ATOMIC); - if (info) { - info->probe_type = type; - info->size = size; - } - - return info; -} -EXPORT_SYMBOL_GPL(probe_info_malloc); - -struct probe_info *probe_info_dup(const struct probe_info *info) -{ - struct probe_info *info_new; - size_t size = info->size; - - info_new = probe_info_malloc(size, info->probe_type); - if (info_new && size) - memcpy(info_new->data, info->data, size); - - return info_new; -} -EXPORT_SYMBOL_GPL(probe_info_dup); - -void probe_info_free(struct probe_info *info) -{ - kfree(info); -} -EXPORT_SYMBOL_GPL(probe_info_free); - - static struct probe_iface *probes_methods[SWAP_PROBE_MAX_VAL] = { NULL }; /* 1 - correct probe type @@ -81,11 +46,11 @@ static inline int correct_probe_type(enum probe_t probe_type) static inline int methods_exist(enum probe_t probe_type) { - if (!correct_probe_type(probe_type)) - return 0; - - if (probes_methods[probe_type] == NULL) + if (!correct_probe_type(probe_type) || + (probes_methods[probe_type] == NULL)) { + printk(KERN_WARNING "SWAP US_MANAGER: Wrong probe type!\n"); return 0; + } return 1; } @@ -97,16 +62,13 @@ static inline int methods_exist(enum probe_t probe_type) * @param ip Pointer to the probe us_ip struct. * @return Void. */ -void probe_info_init(struct probe_info *pi, struct us_ip *ip) +void probe_info_init(enum probe_t type, struct us_ip *ip) { - enum probe_t probe_type = pi->probe_type; - - if (!methods_exist(probe_type)) { - printk(KERN_WARNING "SWAP US_MANAGER: Wrong probe type!\n"); + if (!methods_exist(type)) { return; } - probes_methods[probe_type]->init(ip); + probes_methods[type]->init(ip); } /** @@ -116,16 +78,13 @@ void probe_info_init(struct probe_info *pi, struct us_ip *ip) * @param ip Pointer to the probe us_ip struct. * @return Void. */ -void probe_info_uninit(struct probe_info *pi, struct us_ip *ip) +void probe_info_uninit(enum probe_t type, struct us_ip *ip) { - enum probe_t probe_type = pi->probe_type; - - if (!methods_exist(probe_type)) { - printk(KERN_WARNING "SWAP US_MANAGER: Wrong probe type!\n"); + if (!methods_exist(type)) { return; } - probes_methods[probe_type]->uninit(ip); + probes_methods[type]->uninit(ip); } /** @@ -135,16 +94,13 @@ void probe_info_uninit(struct probe_info *pi, struct us_ip *ip) * @param ip Pointer to the probe us_ip struct. * @return -EINVAL on wrong probe type, method result otherwise. */ -int probe_info_register(struct probe_info *pi, struct us_ip *ip) +int probe_info_register(enum probe_t type, struct us_ip *ip) { - enum probe_t probe_type = pi->probe_type; - - if (!methods_exist(probe_type)) { - printk(KERN_WARNING "SWAP US_MANAGER: Wrong probe type!\n"); + if (!methods_exist(type)) { return -EINVAL; } - return probes_methods[probe_type]->reg(ip); + return probes_methods[type]->reg(ip); } /** @@ -155,16 +111,13 @@ int probe_info_register(struct probe_info *pi, struct us_ip *ip) * @param disarm Disarm flag. * @return Void. */ -void probe_info_unregister(struct probe_info *pi, struct us_ip *ip, int disarm) +void probe_info_unregister(enum probe_t type, struct us_ip *ip, int disarm) { - enum probe_t probe_type = pi->probe_type; - - if (!methods_exist(probe_type)) { - printk(KERN_WARNING "SWAP US_MANAGER: Wrong probe type!\n"); + if (!methods_exist(type)) { return; } - probes_methods[probe_type]->unreg(ip, disarm); + probes_methods[type]->unreg(ip, disarm); } /** @@ -174,53 +127,13 @@ void probe_info_unregister(struct probe_info *pi, struct us_ip *ip, int disarm) * @param ip Pointer to the probe us_ip struct. * @return Pointer to the uprobe struct, NULL on error. */ -struct uprobe *probe_info_get_uprobe(struct probe_info *pi, struct us_ip *ip) +struct uprobe *probe_info_get_uprobe(enum probe_t type, struct us_ip *ip) { - enum probe_t probe_type = pi->probe_type; - - if (!methods_exist(probe_type)) { - printk(KERN_WARNING "SWAP US_MANAGER: Wrong probe type!\n"); + if (!methods_exist(type)) { return NULL; } - return probes_methods[probe_type]->get_uprobe(ip); -} - -/** - * @brief Calls specified probe type copy method. - * - * @param pi Pointer to the source probe_info. - * @param dest Pointer to the probe us_ip struct. - * @return -EINVAL on error, method result otherwise. - */ -int probe_info_copy(const struct probe_info *pi, struct probe_info *dest) -{ - enum probe_t probe_type = pi->probe_type; - - if (!methods_exist(probe_type)) { - printk(KERN_WARNING "SWAP US_MANAGER: Wrong probe type!\n"); - return -EINVAL; - } - - return probes_methods[probe_type]->copy(dest, pi); -} - -/** - * @brief Calls specified probe type cleanup method. - * - * @param pi Pointer to the source probe_info. - * @return Void. - */ -void probe_info_cleanup(struct probe_info *pi) -{ - enum probe_t probe_type = pi->probe_type; - - if (!methods_exist(probe_type)) { - printk(KERN_WARNING "SWAP US_MANAGER: Wrong probe type!\n"); - return; - } - - probes_methods[probe_type]->cleanup(pi); + return probes_methods[type]->get_uprobe(ip); } /** @@ -233,7 +146,7 @@ void probe_info_cleanup(struct probe_info *pi) int swap_register_probe_type(enum probe_t probe_type, struct probe_iface *pi) { if (!correct_probe_type(probe_type)) { - printk(KERN_ERR "SWAP US_MANAGER: Wrong probe type!\n"); + printk(KERN_ERR "SWAP US_MANAGER: incorrect probe type!\n"); return -EINVAL; } @@ -256,7 +169,7 @@ EXPORT_SYMBOL_GPL(swap_register_probe_type); void swap_unregister_probe_type(enum probe_t probe_type) { if (!correct_probe_type(probe_type)) { - printk(KERN_ERR "SWAP US_MANAGER: Wrong probe type!\n"); + printk(KERN_ERR "SWAP US_MANAGER: incorrect probe type!\n"); return; } diff --git a/us_manager/probes/probes.h b/us_manager/probes/probes.h index a911d10..fa40dd1 100644 --- a/us_manager/probes/probes.h +++ b/us_manager/probes/probes.h @@ -35,6 +35,7 @@ #define __PROBES_H__ #include +#include #include /* TODO Remove */ #include /* TODO Remove */ @@ -61,8 +62,6 @@ enum probe_t { /* Probe info stuct. It contains the whole information about probe. */ struct probe_info { - enum probe_t probe_type; - size_t size; /* Union of all SWAP supported probe types */ union { struct retprobe_info rp_i; @@ -72,21 +71,29 @@ struct probe_info { struct get_call_type_info gct_i; struct write_msg_info wm_i; }; - - char data[0]; }; +struct probe_desc { + enum probe_t type; + unsigned long offset; -#define probe_info_create(val_t, type) probe_info_malloc(sizeof(val_t), type) -struct probe_info *probe_info_malloc(size_t size, enum probe_t type); -struct probe_info *probe_info_dup(const struct probe_info *info); -void probe_info_free(struct probe_info *info); - + union { + struct { + uprobe_pre_handler_t handler; + } p; -#define probe_info_get_data(info) ((void *)(info->data)) -#define probe_info_get_ptr(info, val_t) (val_t *)probe_info_get_data(info) -#define probe_info_get_val(info, val_t) *probe_info_get_ptr(info, val_t) -#define probe_info_set_val(info, val_t, v) *probe_info_get_ptr(info, val_t) = v + struct { + uretprobe_handler_t entry_handler; + uretprobe_handler_t ret_handler; + /* + * FIXME: make dynamic size, + * currently data_size = sizeof(void *) + */ + size_t data_size; + } rp; + } u; + struct probe_info info; +}; #endif /* __PROBES_H__ */ diff --git a/us_manager/probes/use_probes.h b/us_manager/probes/use_probes.h index 80cfb3a..294742f 100644 --- a/us_manager/probes/use_probes.h +++ b/us_manager/probes/use_probes.h @@ -5,11 +5,11 @@ struct us_ip; -void probe_info_init(struct probe_info *pi, struct us_ip *ip); -void probe_info_uninit(struct probe_info *pi, struct us_ip *ip); -int probe_info_register(struct probe_info *pi, struct us_ip *ip); -void probe_info_unregister(struct probe_info *pi, struct us_ip *ip, int disarm); -struct uprobe *probe_info_get_uprobe(struct probe_info *pi, struct us_ip *ip); +void probe_info_init(enum probe_t type, struct us_ip *ip); +void probe_info_uninit(enum probe_t type, struct us_ip *ip); +int probe_info_register(enum probe_t type, struct us_ip *ip); +void probe_info_unregister(enum probe_t type, struct us_ip *ip, int disarm); +struct uprobe *probe_info_get_uprobe(enum probe_t type, struct us_ip *ip); int probe_info_copy(const struct probe_info *pi, struct probe_info *dest); void probe_info_cleanup(struct probe_info *pi); diff --git a/us_manager/sspt/ip.c b/us_manager/sspt/ip.c index 7275353..3625181 100644 --- a/us_manager/sspt/ip.c +++ b/us_manager/sspt/ip.c @@ -28,6 +28,7 @@ #include "sspt_page.h" #include "sspt_file.h" #include +#include /** * @brief Create us_ip struct @@ -38,33 +39,21 @@ * @param page Pointer to the parent sspt_page struct * @return Pointer to the created us_ip struct */ -struct us_ip *create_ip(unsigned long offset, const struct probe_info *info, - struct sspt_page *page) +struct us_ip *create_ip(struct img_ip *img_ip) { struct us_ip *ip; - struct probe_info *info_new; - - info_new = probe_info_dup(info); - if (info_new == NULL) { - printk("Cannot probe_info_dup in %s function!\n", __func__); - return NULL; - } ip = kmalloc(sizeof(*ip), GFP_ATOMIC); - if (ip != NULL) { - memset(ip, 0, sizeof(*ip)); - - INIT_LIST_HEAD(&ip->list); - ip->offset = offset; - ip->page = page; + if (!ip) + return NULL; - probe_info_copy(info, info_new); - probe_info_init(info_new, ip); - ip->info = info_new; - } else { - printk(KERN_INFO "Cannot kmalloc in create_ip function!\n"); - probe_info_free(info_new); - } + memset(ip, 0, sizeof(*ip)); + INIT_LIST_HEAD(&ip->list); + INIT_LIST_HEAD(&ip->img_list); + ip->offset = img_ip->addr; + ip->desc = &img_ip->desc; + ip->iip = img_ip; + list_add(&ip->img_list, &img_ip->ihead); return ip; } @@ -77,7 +66,8 @@ struct us_ip *create_ip(unsigned long offset, const struct probe_info *info, */ void free_ip(struct us_ip *ip) { - probe_info_uninit(ip->info, ip); - probe_info_free(ip->info); + if (!list_empty(&ip->img_list)) + list_del(&ip->img_list); + kfree(ip); } diff --git a/us_manager/sspt/ip.h b/us_manager/sspt/ip.h index f895b20..22f2760 100644 --- a/us_manager/sspt/ip.h +++ b/us_manager/sspt/ip.h @@ -37,7 +37,9 @@ struct sspt_page; struct us_ip { struct list_head list; /**< For sspt_page */ struct sspt_page *page; /**< Pointer on the page (parent) */ - struct probe_info *info; /**< Probe's data */ + struct probe_desc *desc; /**< Probe's data */ + struct img_ip *iip; + struct list_head img_list; unsigned long orig_addr; /**< Function address */ unsigned long offset; /**< Page offset */ @@ -50,8 +52,7 @@ struct us_ip { #define to_us_ip(rp) container_of(rp, struct us_ip, retprobe) -struct us_ip *create_ip(unsigned long offset, const struct probe_info *info, - struct sspt_page *page); +struct us_ip *create_ip(struct img_ip *img_ip); void free_ip(struct us_ip *ip); #endif /* __IP__ */ diff --git a/us_manager/sspt/sspt.h b/us_manager/sspt/sspt.h index cd54010..026c776 100644 --- a/us_manager/sspt/sspt.h +++ b/us_manager/sspt/sspt.h @@ -51,7 +51,7 @@ static inline int sspt_register_usprobe(struct us_ip *ip) int ret; struct uprobe *up = NULL; - up = probe_info_get_uprobe(ip->info, ip); + up = probe_info_get_uprobe(ip->desc->type, ip); if (!up) { printk(KERN_INFO "SWAP US_MANAGER: failed getting uprobe!\n"); @@ -62,16 +62,16 @@ static inline int sspt_register_usprobe(struct us_ip *ip) up->task = ip->page->file->proc->task; up->sm = ip->page->file->proc->sm; - ret = probe_info_register(ip->info, ip); + ret = probe_info_register(ip->desc->type, ip); if (ret) { struct sspt_file *file = ip->page->file; char *name = file->dentry->d_iname; unsigned long addr = (unsigned long)up->addr; unsigned long offset = addr - file->vm_start; - printk(KERN_INFO "swap_register_uretprobe() failure %d " - "(%s:%lx|%lx)\n", ret, name, offset, - (unsigned long)ip->retprobe.up.opcode); + printk(KERN_ERR "probe_info_register failed %d (%s:%lx|%lx)\n", + ret, name, offset, + (unsigned long)ip->retprobe.up.opcode); } return ret; @@ -85,14 +85,14 @@ static inline int sspt_unregister_usprobe(struct task_struct *task, switch (flag) { case US_UNREGS_PROBE: - probe_info_unregister(ip->info, ip, 1); + probe_info_unregister(ip->desc->type, ip, 1); break; case US_DISARM: - up = probe_info_get_uprobe(ip->info, ip); + up = probe_info_get_uprobe(ip->desc->type, ip); disarm_uprobe(up, task); break; case US_UNINSTALL: - probe_info_unregister(ip->info, ip, 0); + probe_info_unregister(ip->desc->type, ip, 0); break; default: panic("incorrect value flag=%d", flag); diff --git a/us_manager/sspt/sspt_debug.h b/us_manager/sspt/sspt_debug.h index 7d7e212..1a1a63e 100644 --- a/us_manager/sspt/sspt_debug.h +++ b/us_manager/sspt/sspt_debug.h @@ -42,7 +42,7 @@ static inline void print_retprobe(struct uretprobe *rp) static inline void print_ip(struct us_ip *ip, int i) { - if (ip->info->probe_type == SWAP_RETPROBE) { + if (ip->desc->type == SWAP_RETPROBE) { struct uretprobe *rp = &ip->retprobe; printk(KERN_INFO "### addr[%2d]=%lx, R_addr=%lx\n", diff --git a/us_manager/sspt/sspt_file.c b/us_manager/sspt/sspt_file.c index 8b88ff0..ab02ce1 100644 --- a/us_manager/sspt/sspt_file.c +++ b/us_manager/sspt/sspt_file.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include static int calculation_hash_bits(int cnt) { @@ -176,16 +178,22 @@ struct sspt_page *sspt_find_page_mapped(struct sspt_file *file, * @param ret_type Return type * @return Void */ -void sspt_file_add_ip(struct sspt_file *file, unsigned long offset, - struct probe_info *probe_i) +void sspt_file_add_ip(struct sspt_file *file, struct img_ip *img_ip) { - struct sspt_page *page = - sspt_find_page_or_new(file, offset & PAGE_MASK); + unsigned long offset = 0; + struct sspt_page *page = NULL; + struct us_ip *ip = NULL; + + offset = img_ip->addr & PAGE_MASK; + page = sspt_find_page_or_new(file, offset); /* FIXME: delete ip */ - struct us_ip *ip = create_ip(offset, probe_i, page); + ip = create_ip(img_ip); + if (!ip) + return; sspt_add_ip(page, ip); + probe_info_init(ip->desc->type, ip); } /** diff --git a/us_manager/sspt/sspt_file.h b/us_manager/sspt/sspt_file.h index 11e8f42..bd542b0 100644 --- a/us_manager/sspt/sspt_file.h +++ b/us_manager/sspt/sspt_file.h @@ -53,8 +53,7 @@ void sspt_file_free(struct sspt_file *file); struct sspt_page *sspt_find_page_mapped(struct sspt_file *file, unsigned long page); -void sspt_file_add_ip(struct sspt_file *file, unsigned long offset, - struct probe_info *probe_i); +void sspt_file_add_ip(struct sspt_file *file, struct img_ip *img_ip); struct sspt_page *sspt_get_page(struct sspt_file *file, unsigned long offset_addr); diff --git a/us_manager/sspt/sspt_page.c b/us_manager/sspt/sspt_page.c index a701ecf..c093b75 100644 --- a/us_manager/sspt/sspt_page.c +++ b/us_manager/sspt/sspt_page.c @@ -94,7 +94,7 @@ static void sspt_list_del_ip(struct us_ip *ip) void sspt_add_ip(struct sspt_page *page, struct us_ip *ip) { ip->offset &= ~PAGE_MASK; - + ip->page = page; sspt_list_add_ip(page, ip); } diff --git a/us_manager/sspt/sspt_proc.c b/us_manager/sspt/sspt_proc.c index 71744a8..65ab7f4 100644 --- a/us_manager/sspt/sspt_proc.c +++ b/us_manager/sspt/sspt_proc.c @@ -266,35 +266,6 @@ struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc, return NULL; } -void sspt_proc_install_probe(struct sspt_proc *proc, unsigned long vaddr, - struct probe_info *probe_i) -{ - struct vm_area_struct *vma; - struct task_struct *task = proc->task; - struct mm_struct *mm = task->mm; - unsigned long page_vaddr = vaddr & PAGE_MASK; - - vma = find_vma_intersection(mm, page_vaddr, page_vaddr + 1); - if (vma && check_vma(vma)) { - struct sspt_file *file; - struct dentry *dentry = vma->vm_file->f_dentry; - - file = sspt_proc_find_file_or_new(proc, dentry); - if (file) { - unsigned long addr = vaddr - vma->vm_start; - struct sspt_page *page; - - sspt_file_set_mapping(file, vma); - sspt_file_add_ip(file, addr, probe_i); - - page = sspt_find_page_mapped(file, page_vaddr); - if (page) - sspt_register_page(page, file); - } - } -} -EXPORT_SYMBOL_GPL(sspt_proc_install_probe); - /** * @brief Install probes on the page to monitored process * diff --git a/us_manager/sspt/sspt_proc.h b/us_manager/sspt/sspt_proc.h index 1b0f9d2..3667b4a 100644 --- a/us_manager/sspt/sspt_proc.h +++ b/us_manager/sspt/sspt_proc.h @@ -71,9 +71,6 @@ struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc, struct dentry *dentry); struct sspt_file *sspt_proc_find_file_or_new(struct sspt_proc *proc, struct dentry *dentry); - -void sspt_proc_install_probe(struct sspt_proc *proc, unsigned long vaddr, - struct probe_info *probe_i); 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, diff --git a/webprobe/webprobe.c b/webprobe/webprobe.c index d73b36c..ce7109a 100644 --- a/webprobe/webprobe.c +++ b/webprobe/webprobe.c @@ -154,7 +154,7 @@ static void webprobe_init(struct us_ip *ip) static void webprobe_uninit(struct us_ip *ip) { - webprobe_cleanup(ip->info); + webprobe_cleanup(&ip->desc->info); } diff --git a/webprobe/webprobe_prof.c b/webprobe/webprobe_prof.c index 9e43670..fffef1c 100644 --- a/webprobe/webprobe_prof.c +++ b/webprobe/webprobe_prof.c @@ -28,6 +28,7 @@ #include #include +#include #include "webprobe_prof.h" @@ -95,10 +96,9 @@ unsigned long web_prof_addr(enum web_prof_addr_t type) static int web_func_inst_add(unsigned long addr) { int ret; - struct probe_info probe; + struct probe_desc probe; - probe.probe_type = SWAP_WEBPROBE; - probe.size = 0; + probe.type = SWAP_WEBPROBE; ret = pf_register_probe(web_data->pfg, web_data->lib_dentry, addr, &probe); diff --git a/wsp/wsp.c b/wsp/wsp.c index 8f40a17..58364df 100644 --- a/wsp/wsp.c +++ b/wsp/wsp.c @@ -44,11 +44,11 @@ static const char webapp_path[] = "/usr/bin/WebProcess"; static const char ewebkit_path[] = "/usr/lib/libewebkit2.so"; -#define WSP_PROBE_MAKE(_name, _info) \ +#define WSP_PROBE_MAKE(__name, __desc) \ { \ - .name = _name, \ + .name = __name, \ .probe.offset = 0, \ - .probe.info = _info \ + .probe.desc = __desc \ } @@ -110,7 +110,7 @@ static int soup_req_handle(struct uprobe *p, struct pt_regs *regs) return 0; } -static struct probe_info_new soup_req = MAKE_UPROBE(soup_req_handle); +static struct probe_desc soup_req = MAKE_UPROBE(soup_req_handle); /* @@ -128,7 +128,7 @@ static int mres_req_handle(struct uprobe *p, struct pt_regs *regs) return 0; } -static struct probe_info_new mres_req = MAKE_UPROBE(mres_req_handle); +static struct probe_desc mres_req = MAKE_UPROBE(mres_req_handle); /* @@ -154,7 +154,7 @@ static int mres_adata_rh(struct uretprobe_instance *ri, struct pt_regs *regs) return 0; } -static struct probe_info_new mres_adata = +static struct probe_desc mres_adata = MAKE_URPROBE(mres_adata_eh, mres_adata_rh, sizeof(struct wsp_res *)); @@ -176,7 +176,7 @@ static int mres_finish_handle(struct uprobe *p, struct pt_regs *regs) return 0; } -static struct probe_info_new mres_finish = MAKE_UPROBE(mres_finish_handle); +static struct probe_desc mres_finish = MAKE_UPROBE(mres_finish_handle); /* @@ -201,7 +201,7 @@ static int res_request_handle(struct uprobe *p, struct pt_regs *regs) return 0; } -static struct probe_info_new res_request = MAKE_UPROBE(res_request_handle); +static struct probe_desc res_request = MAKE_UPROBE(res_request_handle); /* @@ -230,7 +230,7 @@ static int res_finish_rhandle(struct uretprobe_instance *ri, return 0; } -static struct probe_info_new res_finish = +static struct probe_desc res_finish = MAKE_URPROBE(res_finish_ehandle, res_finish_rhandle, sizeof(struct wsp_res *)); @@ -260,7 +260,7 @@ static int redraw_rh(struct uretprobe_instance *ri, struct pt_regs *regs) return 0; } -static struct probe_info_new redraw = MAKE_URPROBE(redraw_eh, redraw_rh, 0); +static struct probe_desc redraw = MAKE_URPROBE(redraw_eh, redraw_rh, 0); static struct wsp_probe ewebkit_probe_array[] = { -- 2.7.4