From: Vyacheslav Cherkashin Date: Thu, 31 Mar 2016 13:14:25 +0000 (+0300) Subject: [REFACTOR] naming in sspt_* X-Git-Tag: submit/tizen/20161124.145503~40^2~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1f84db4ec4fd2604b78a5c5626370f73fbbf219;p=kernel%2Fswap-modules.git [REFACTOR] naming in sspt_* Change-Id: I92206c9ee15895d9dc641d3548a6defc75bdf074 Signed-off-by: Vyacheslav Cherkashin --- diff --git a/fbiprobe/fbiprobe.c b/fbiprobe/fbiprobe.c index 535921c..b0c443c 100644 --- a/fbiprobe/fbiprobe.c +++ b/fbiprobe/fbiprobe.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include @@ -216,7 +216,7 @@ exit: } static int fbi_probe_get_data_from_direct_addr(const struct fbi_var_data *fbi_i, - struct us_ip *ip, + struct sspt_ip *ip, struct pt_regs *regs) { struct vm_area_struct *vma; @@ -257,7 +257,7 @@ 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 sspt_ip *ip = container_of(p, struct sspt_ip, uprobe); struct fbi_info *fbi_i = &ip->desc->info.fbi_i; struct fbi_var_data *fbi_d = NULL; uint8_t i; @@ -305,28 +305,28 @@ void fbi_probe_cleanup(struct probe_info *probe_i) fbi_i->vars = NULL; } -void fbi_probe_init(struct us_ip *ip) +void fbi_probe_init(struct sspt_ip *ip) { ip->uprobe.pre_handler = (uprobe_pre_handler_t)fbi_probe_handler; } -void fbi_probe_uninit(struct us_ip *ip) +void fbi_probe_uninit(struct sspt_ip *ip) { if (ip != NULL) fbi_probe_cleanup(&ip->desc->info); } -static int fbi_probe_register_probe(struct us_ip *ip) +static int fbi_probe_register_probe(struct sspt_ip *ip) { return swap_register_uprobe(&ip->uprobe); } -static void fbi_probe_unregister_probe(struct us_ip *ip, int disarm) +static void fbi_probe_unregister_probe(struct sspt_ip *ip, int disarm) { __swap_unregister_uprobe(&ip->uprobe, disarm); } -static struct uprobe *fbi_probe_get_uprobe(struct us_ip *ip) +static struct uprobe *fbi_probe_get_uprobe(struct sspt_ip *ip) { return &ip->uprobe; } diff --git a/nsp/nsp.c b/nsp/nsp.c index 8fee92b..dcc42c1 100644 --- a/nsp/nsp.c +++ b/nsp/nsp.c @@ -703,10 +703,10 @@ static int main_eh(struct uretprobe_instance *ri, struct pt_regs *regs) main_h(&rp->up, regs); if (get_quiet() == QT_OFF) { - struct us_ip *ip; + struct sspt_ip *ip; unsigned long func_addr; - ip = container_of(rp, struct us_ip, retprobe); + ip = container_of(rp, struct sspt_ip, retprobe); func_addr = (unsigned long)ip->orig_addr; rp_msg_entry(regs, func_addr, "p"); } @@ -720,11 +720,11 @@ static int main_rh(struct uretprobe_instance *ri, struct pt_regs *regs) struct uretprobe *rp = ri->rp; if (rp && get_quiet() == QT_OFF) { - struct us_ip *ip; + struct sspt_ip *ip; unsigned long func_addr; unsigned long ret_addr; - ip = container_of(rp, struct us_ip, retprobe); + ip = container_of(rp, struct sspt_ip, retprobe); func_addr = (unsigned long)ip->orig_addr; ret_addr = (unsigned long)ri->ret_addr; rp_msg_exit(regs, func_addr, 'n', ret_addr); diff --git a/preload/preload_control.c b/preload/preload_control.c index c4a07ef..841ab28 100644 --- a/preload/preload_control.c +++ b/preload/preload_control.c @@ -3,7 +3,7 @@ #include #include -#include +#include #include "preload.h" #include "preload_control.h" @@ -211,7 +211,7 @@ enum preload_call_type preload_control_call_type_always_inst(void *caller) } -enum preload_call_type preload_control_call_type(struct us_ip *ip, void *caller) +enum preload_call_type preload_control_call_type(struct sspt_ip *ip, void *caller) { if (__is_instrumented(caller)) return INTERNAL_CALL; diff --git a/preload/preload_control.h b/preload/preload_control.h index 67ca2ee..419d61e 100644 --- a/preload/preload_control.h +++ b/preload/preload_control.h @@ -1,7 +1,7 @@ #ifndef __PRELOAD_CONTROL_H__ #define __PRELOAD_CONTROL_H__ -struct us_ip; +struct sspt_ip; enum preload_call_type { NOT_INSTRUMENTED, @@ -13,7 +13,7 @@ int preload_control_init(void); void preload_control_exit(void); enum preload_call_type preload_control_call_type_always_inst(void *caller); -enum preload_call_type preload_control_call_type(struct us_ip *ip, void *caller); +enum preload_call_type preload_control_call_type(struct sspt_ip *ip, void *caller); int preload_control_add_instrumented_binary(char *filename); int preload_control_clean_instrumented_bins(void); int preload_control_add_ignored_binary(char *filename); diff --git a/preload/preload_handlers.c b/preload/preload_handlers.c index 578cebf..ec5fa84 100644 --- a/preload/preload_handlers.c +++ b/preload/preload_handlers.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include "preload.h" @@ -13,6 +13,7 @@ #define page_to_proc(page) ((page)->file->proc) #define ip_to_proc(ip) page_to_proc((ip)->page) +#define urp_to_ip(rp) container_of(rp, struct sspt_ip, retprobe) enum { /* task preload flags */ @@ -24,7 +25,7 @@ static struct dentry *handler_dentry = NULL; static inline struct pd_t *__get_process_data(struct uretprobe *rp) { - struct us_ip *ip = to_us_ip(rp); + struct sspt_ip *ip = urp_to_ip(rp); struct sspt_proc *proc = ip_to_proc(ip); return preload_pd_get(proc); @@ -42,7 +43,7 @@ static inline struct vm_area_struct *__get_vma_by_addr(struct task_struct *task, return vma; } -static inline bool __is_probe_non_block(struct us_ip *ip) +static inline bool __is_probe_non_block(struct sspt_ip *ip) { if (ip->desc->info.pl_i.flags & SWAP_PRELOAD_NON_BLOCK_PROBE) return true; @@ -50,7 +51,7 @@ static inline bool __is_probe_non_block(struct us_ip *ip) return false; } -static inline bool __inverted(struct us_ip *ip) +static inline bool __inverted(struct sspt_ip *ip) { unsigned long flags = ip->desc->info.pl_i.flags; @@ -60,7 +61,7 @@ static inline bool __inverted(struct us_ip *ip) return false; } -static inline bool __check_flag_and_call_type(struct us_ip *ip, +static inline bool __check_flag_and_call_type(struct sspt_ip *ip, enum preload_call_type ct) { bool inverted = __inverted(ip); @@ -88,7 +89,7 @@ static inline bool __is_handlers_call(struct vm_area_struct *caller, return false; } -static inline bool __should_drop(struct us_ip *ip, enum preload_call_type ct) +static inline bool __should_drop(struct sspt_ip *ip, enum preload_call_type ct) { if (ct == NOT_INSTRUMENTED) return true; @@ -113,7 +114,7 @@ static unsigned long __do_preload_entry(struct uretprobe_instance *ri, struct pt_regs *regs, struct hd_t *hd) { - struct us_ip *ip = container_of(ri->rp, struct us_ip, retprobe); + struct sspt_ip *ip = container_of(ri->rp, struct sspt_ip, retprobe); unsigned long offset = ip->desc->info.pl_i.handler; unsigned long vaddr = 0; unsigned long base; @@ -173,7 +174,7 @@ static int preload_us_entry(struct uretprobe_instance *ri, struct pt_regs *regs) struct hd_t *hd; unsigned long old_pc = swap_get_instr_ptr(regs); unsigned long flags = get_preload_flags(current); - struct us_ip *ip = container_of(ri->rp, struct us_ip, retprobe); + struct sspt_ip *ip = container_of(ri->rp, struct sspt_ip, retprobe); unsigned long vaddr = 0; if (handler_dentry == NULL) @@ -206,7 +207,7 @@ out_set_orig: static void __do_preload_ret(struct uretprobe_instance *ri, struct hd_t *hd) { - struct us_ip *ip = container_of(ri->rp, struct us_ip, retprobe); + struct sspt_ip *ip = container_of(ri->rp, struct sspt_ip, retprobe); unsigned long flags = get_preload_flags(current); unsigned long offset = ip->desc->info.pl_i.handler; unsigned long vaddr = 0; @@ -410,7 +411,7 @@ static int get_call_type_handler(struct uprobe *p, struct pt_regs *regs) -int ph_get_caller_init(struct us_ip *ip) +int ph_get_caller_init(struct sspt_ip *ip) { struct uprobe *up = &ip->uprobe; @@ -419,11 +420,11 @@ int ph_get_caller_init(struct us_ip *ip) return 0; } -void ph_get_caller_exit(struct us_ip *ip) +void ph_get_caller_exit(struct sspt_ip *ip) { } -int ph_get_call_type_init(struct us_ip *ip) +int ph_get_call_type_init(struct sspt_ip *ip) { struct uprobe *up = &ip->uprobe; @@ -432,11 +433,11 @@ int ph_get_call_type_init(struct us_ip *ip) return 0; } -void ph_get_call_type_exit(struct us_ip *ip) +void ph_get_call_type_exit(struct sspt_ip *ip) { } -int ph_write_msg_init(struct us_ip *ip) +int ph_write_msg_init(struct sspt_ip *ip) { struct uprobe *up = &ip->uprobe; @@ -445,7 +446,7 @@ int ph_write_msg_init(struct us_ip *ip) return 0; } -void ph_write_msg_exit(struct us_ip *ip) +void ph_write_msg_exit(struct sspt_ip *ip) { } @@ -455,7 +456,7 @@ void ph_set_handler_dentry(struct dentry *dentry) } -int ph_uprobe_init(struct us_ip *ip) +int ph_uprobe_init(struct sspt_ip *ip) { struct uretprobe *rp = &ip->retprobe; @@ -468,6 +469,6 @@ int ph_uprobe_init(struct us_ip *ip) return 0; } -void ph_uprobe_exit(struct us_ip *ip) +void ph_uprobe_exit(struct sspt_ip *ip) { } diff --git a/preload/preload_handlers.h b/preload/preload_handlers.h index bf1fbfb..04e4360 100644 --- a/preload/preload_handlers.h +++ b/preload/preload_handlers.h @@ -1,18 +1,18 @@ #ifndef __PRELOAD_HANDLERS_H__ #define __PRELOAD_HANDLERS_H__ -struct us_ip; +struct sspt_ip; struct dentry; -int ph_uprobe_init(struct us_ip *ip); -void ph_uprobe_exit(struct us_ip *ip); +int ph_uprobe_init(struct sspt_ip *ip); +void ph_uprobe_exit(struct sspt_ip *ip); -int ph_get_caller_init(struct us_ip *ip); -void ph_get_caller_exit(struct us_ip *ip); -int ph_get_call_type_init(struct us_ip *ip); -void ph_get_call_type_exit(struct us_ip *ip); -int ph_write_msg_init(struct us_ip *ip); -void ph_write_msg_exit(struct us_ip *ip); +int ph_get_caller_init(struct sspt_ip *ip); +void ph_get_caller_exit(struct sspt_ip *ip); +int ph_get_call_type_init(struct sspt_ip *ip); +void ph_get_call_type_exit(struct sspt_ip *ip); +int ph_write_msg_init(struct sspt_ip *ip); +void ph_write_msg_exit(struct sspt_ip *ip); void ph_set_handler_dentry(struct dentry *dentry); #endif /* __PRELOAD_HANDLERS_H__ */ diff --git a/preload/preload_module.c b/preload/preload_module.c index 622621c..b8d613d 100644 --- a/preload/preload_module.c +++ b/preload/preload_module.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/preload/preload_probe.c b/preload/preload_probe.c index a52b39c..4a44139 100644 --- a/preload/preload_probe.c +++ b/preload/preload_probe.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "preload_probe.h" #include "preload.h" #include "preload_module.h" @@ -48,7 +48,7 @@ static void preload_info_cleanup(struct probe_info *probe_i) { } -static struct uprobe *preload_get_uprobe(struct us_ip *ip) +static struct uprobe *preload_get_uprobe(struct sspt_ip *ip) { return &ip->retprobe.up; } @@ -96,7 +96,7 @@ static inline bool can_be_ready(void) /* Registers probe if preload is 'running' or 'ready'. */ -static int preload_register_probe(struct us_ip *ip) +static int preload_register_probe(struct sspt_ip *ip) { if (preload_module_is_not_ready()) { if (can_be_ready()) { @@ -112,19 +112,19 @@ static int preload_register_probe(struct us_ip *ip) return swap_register_uretprobe(&ip->retprobe); } -static void preload_unregister_probe(struct us_ip *ip, int disarm) +static void preload_unregister_probe(struct sspt_ip *ip, int disarm) { __swap_unregister_uretprobe(&ip->retprobe, disarm); dec_probes(); } -static void preload_init(struct us_ip *ip) +static void preload_init(struct sspt_ip *ip) { ph_uprobe_init(ip); } -static void preload_uninit(struct us_ip *ip) +static void preload_uninit(struct sspt_ip *ip) { ph_uprobe_exit(ip); @@ -153,27 +153,27 @@ static void get_caller_info_cleanup(struct probe_info *probe_i) { } -static struct uprobe *get_caller_get_uprobe(struct us_ip *ip) +static struct uprobe *get_caller_get_uprobe(struct sspt_ip *ip) { return &ip->uprobe; } -static int get_caller_register_probe(struct us_ip *ip) +static int get_caller_register_probe(struct sspt_ip *ip) { return swap_register_uprobe(&ip->uprobe); } -static void get_caller_unregister_probe(struct us_ip *ip, int disarm) +static void get_caller_unregister_probe(struct sspt_ip *ip, int disarm) { __swap_unregister_uprobe(&ip->uprobe, disarm); } -static void get_caller_init(struct us_ip *ip) +static void get_caller_init(struct sspt_ip *ip) { ph_get_caller_init(ip); } -static void get_caller_uninit(struct us_ip *ip) +static void get_caller_uninit(struct sspt_ip *ip) { ph_get_caller_exit(ip); @@ -190,12 +190,12 @@ static struct probe_iface get_caller_iface = { .cleanup = get_caller_info_cleanup }; -static void get_call_type_init(struct us_ip *ip) +static void get_call_type_init(struct sspt_ip *ip) { ph_get_call_type_init(ip); } -static void get_call_type_uninit(struct us_ip *ip) +static void get_call_type_uninit(struct sspt_ip *ip) { ph_get_call_type_exit(ip); @@ -212,17 +212,17 @@ static struct probe_iface get_call_type_iface = { .cleanup = get_caller_info_cleanup }; -static void write_msg_init(struct us_ip *ip) +static void write_msg_init(struct sspt_ip *ip) { ph_write_msg_init(ip); } -static int write_msg_reg(struct us_ip *ip) +static int write_msg_reg(struct sspt_ip *ip) { return get_caller_register_probe(ip); } -static void write_msg_uninit(struct us_ip *ip) +static void write_msg_uninit(struct sspt_ip *ip) { ph_write_msg_exit(ip); diff --git a/retprobe/retprobe.c b/retprobe/retprobe.c index 51cf83a..db5b75a 100644 --- a/retprobe/retprobe.c +++ b/retprobe/retprobe.c @@ -24,7 +24,7 @@ #include "retprobe.h" #include -#include +#include #include #include #include @@ -56,17 +56,17 @@ static void retprobe_cleanup(struct probe_info *probe_i) -static struct uprobe *retprobe_get_uprobe(struct us_ip *ip) +static struct uprobe *retprobe_get_uprobe(struct sspt_ip *ip) { return &ip->retprobe.up; } -static int retprobe_register_probe(struct us_ip *ip) +static int retprobe_register_probe(struct sspt_ip *ip) { return swap_register_uretprobe(&ip->retprobe); } -static void retprobe_unregister_probe(struct us_ip *ip, int disarm) +static void retprobe_unregister_probe(struct sspt_ip *ip, int disarm) { __swap_unregister_uretprobe(&ip->retprobe, disarm); } @@ -77,7 +77,7 @@ static int retprobe_entry_handler(struct uretprobe_instance *ri, struct pt_regs struct uretprobe *rp = ri->rp; if (rp && get_quiet() == QT_OFF) { - struct us_ip *ip = container_of(rp, struct us_ip, retprobe); + struct sspt_ip *ip = container_of(rp, struct sspt_ip, retprobe); const char *fmt = ip->desc->info.rp_i.args; const unsigned long func_addr = (unsigned long)ip->orig_addr; @@ -92,7 +92,7 @@ static int retprobe_ret_handler(struct uretprobe_instance *ri, struct pt_regs *r struct uretprobe *rp = ri->rp; if (rp && get_quiet() == QT_OFF) { - struct us_ip *ip = container_of(rp, struct us_ip, retprobe); + struct sspt_ip *ip = container_of(rp, struct sspt_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->desc->info.rp_i.ret_type; @@ -103,14 +103,14 @@ static int retprobe_ret_handler(struct uretprobe_instance *ri, struct pt_regs *r return 0; } -static void retprobe_init(struct us_ip *ip) +static void retprobe_init(struct sspt_ip *ip) { ip->retprobe.entry_handler = retprobe_entry_handler; ip->retprobe.handler = retprobe_ret_handler; ip->retprobe.maxactive = 0; } -static void retprobe_uninit(struct us_ip *ip) +static void retprobe_uninit(struct sspt_ip *ip) { retprobe_cleanup(&ip->desc->info); } diff --git a/us_manager/Kbuild b/us_manager/Kbuild index 64e4d35..5f56498 100644 --- a/us_manager/Kbuild +++ b/us_manager/Kbuild @@ -4,11 +4,22 @@ KBUILD_EXTRA_SYMBOLS = $(src)/../writer/Module.symvers \ $(src)/../uprobe/Module.symvers obj-m := swap_us_manager.o -swap_us_manager-y := us_manager.o us_slot_manager.o helper.o debugfs_us_manager.o \ - sspt/ip.o sspt/sspt_page.o sspt/sspt_file.o sspt/sspt_proc.o \ - sspt/sspt_feature.o sspt/sspt_filter.o \ - pf/proc_filters.o pf/pf_group.o \ - img/img_proc.o img/img_file.o img/img_ip.o \ - probes/probes.o \ - probes/probe_info_new.o \ - callbacks.o +swap_us_manager-y := \ + helper.o \ + us_manager.o \ + us_slot_manager.o \ + debugfs_us_manager.o \ + sspt/sspt_ip.o \ + sspt/sspt_page.o \ + sspt/sspt_file.o \ + sspt/sspt_proc.o \ + sspt/sspt_feature.o \ + sspt/sspt_filter.o \ + pf/pf_group.o \ + pf/proc_filters.o \ + img/img_ip.o \ + img/img_file.o \ + img/img_proc.o \ + probes/probes.o \ + probes/probe_info_new.o \ + callbacks.o diff --git a/us_manager/helper.c b/us_manager/helper.c index ac30ffc..92d829b 100644 --- a/us_manager/helper.c +++ b/us_manager/helper.c @@ -148,7 +148,7 @@ static void unregister_mf(void) * copy_process() * ****************************************************************************** */ -static void func_uinst_creare(struct us_ip *ip, void *data) +static void func_uinst_creare(struct sspt_ip *ip, void *data) { struct hlist_head *head = (struct hlist_head *)data; struct uprobe *up; diff --git a/us_manager/img/img_ip.c b/us_manager/img/img_ip.c index 5ec1e9a..7a9cc67 100644 --- a/us_manager/img/img_ip.c +++ b/us_manager/img/img_ip.c @@ -25,7 +25,7 @@ #include "img_ip.h" #include -#include +#include #include /** @@ -59,14 +59,14 @@ struct img_ip *create_img_ip(unsigned long addr, struct probe_desc *pd) */ void free_img_ip(struct img_ip *ip) { - struct us_ip *p, *n; + struct sspt_ip *p, *n; list_for_each_entry_safe(p, n, &ip->ihead, img_list) { list_del_init(&p->img_list); - p->iip = NULL; + p->img_ip = NULL; list_del(&p->list); probe_info_unregister(p->desc->type, p, 1); - free_ip(p); + sspt_ip_free(p); } kfree(ip); diff --git a/us_manager/probes/probe_info_new.c b/us_manager/probes/probe_info_new.c index b5a05bd..6a1e0a3 100644 --- a/us_manager/probes/probe_info_new.c +++ b/us_manager/probes/probe_info_new.c @@ -21,7 +21,7 @@ #include -#include +#include #include #include #include "probes.h" @@ -37,7 +37,7 @@ static int urp_entry_handler(struct uretprobe_instance *ri, struct pt_regs *regs struct uretprobe *rp = ri->rp; if (rp) { - struct us_ip *ip = container_of(rp, struct us_ip, retprobe); + struct sspt_ip *ip = container_of(rp, struct sspt_ip, retprobe); struct probe_desc *pd = NULL; pd = ip->desc; @@ -54,7 +54,7 @@ static int urp_ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs) struct uretprobe *rp = ri->rp; if (rp) { - struct us_ip *ip = container_of(rp, struct us_ip, retprobe); + struct sspt_ip *ip = container_of(rp, struct sspt_ip, retprobe); struct probe_desc *pd = NULL; pd = ip->desc; @@ -67,7 +67,7 @@ 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 sspt_ip *ip = container_of(p, struct sspt_ip, uprobe); struct probe_desc *pd = NULL; pd = ip->desc; @@ -127,27 +127,27 @@ static void up_cleanup(struct probe_info *probe_i) { } -static struct uprobe *up_get_uprobe(struct us_ip *ip) +static struct uprobe *up_get_uprobe(struct sspt_ip *ip) { return &ip->uprobe; } -static int up_register_probe(struct us_ip *ip) +static int up_register_probe(struct sspt_ip *ip) { return swap_register_uprobe(&ip->uprobe); } -static void up_unregister_probe(struct us_ip *ip, int disarm) +static void up_unregister_probe(struct sspt_ip *ip, int disarm) { __swap_unregister_uprobe(&ip->uprobe, disarm); } -static void up_init(struct us_ip *ip) +static void up_init(struct sspt_ip *ip) { ip->uprobe.pre_handler = uprobe_handler; } -static void up_uninit(struct us_ip *ip) +static void up_uninit(struct sspt_ip *ip) { } @@ -177,22 +177,22 @@ static void urp_cleanup(struct probe_info *probe_i) { } -static struct uprobe *urp_get_uprobe(struct us_ip *ip) +static struct uprobe *urp_get_uprobe(struct sspt_ip *ip) { return &ip->retprobe.up; } -static int urp_register_probe(struct us_ip *ip) +static int urp_register_probe(struct sspt_ip *ip) { return swap_register_uretprobe(&ip->retprobe); } -static void urp_unregister_probe(struct us_ip *ip, int disarm) +static void urp_unregister_probe(struct sspt_ip *ip, int disarm) { __swap_unregister_uretprobe(&ip->retprobe, disarm); } -static void urp_init(struct us_ip *ip) +static void urp_init(struct sspt_ip *ip) { ip->retprobe.entry_handler = urp_entry_handler; ip->retprobe.handler = urp_ret_handler; @@ -201,7 +201,7 @@ static void urp_init(struct us_ip *ip) ip->retprobe.data_size = sizeof(void *); } -static void urp_uninit(struct us_ip *ip) +static void urp_uninit(struct sspt_ip *ip) { } diff --git a/us_manager/probes/probes.c b/us_manager/probes/probes.c index 3d1aef7..37f59f1 100644 --- a/us_manager/probes/probes.c +++ b/us_manager/probes/probes.c @@ -62,7 +62,7 @@ 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(enum probe_t type, struct us_ip *ip) +void probe_info_init(enum probe_t type, struct sspt_ip *ip) { if (!methods_exist(type)) { return; @@ -78,7 +78,7 @@ void probe_info_init(enum probe_t type, struct us_ip *ip) * @param ip Pointer to the probe us_ip struct. * @return Void. */ -void probe_info_uninit(enum probe_t type, struct us_ip *ip) +void probe_info_uninit(enum probe_t type, struct sspt_ip *ip) { if (!methods_exist(type)) { return; @@ -94,7 +94,7 @@ void probe_info_uninit(enum probe_t type, 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(enum probe_t type, struct us_ip *ip) +int probe_info_register(enum probe_t type, struct sspt_ip *ip) { if (!methods_exist(type)) { return -EINVAL; @@ -111,7 +111,7 @@ int probe_info_register(enum probe_t type, struct us_ip *ip) * @param disarm Disarm flag. * @return Void. */ -void probe_info_unregister(enum probe_t type, struct us_ip *ip, int disarm) +void probe_info_unregister(enum probe_t type, struct sspt_ip *ip, int disarm) { if (!methods_exist(type)) { return; @@ -127,7 +127,7 @@ void probe_info_unregister(enum probe_t type, 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(enum probe_t type, struct us_ip *ip) +struct uprobe *probe_info_get_uprobe(enum probe_t type, struct sspt_ip *ip) { if (!methods_exist(type)) { return NULL; diff --git a/us_manager/probes/register_probes.h b/us_manager/probes/register_probes.h index fb6a244..f981056 100644 --- a/us_manager/probes/register_probes.h +++ b/us_manager/probes/register_probes.h @@ -3,14 +3,14 @@ #include "probes.h" -struct us_ip; +struct sspt_ip; struct probe_iface { - void (*init)(struct us_ip *); - void (*uninit)(struct us_ip *); - int (*reg)(struct us_ip *); - void (*unreg)(struct us_ip *, int); - struct uprobe *(*get_uprobe)(struct us_ip *); + void (*init)(struct sspt_ip *); + void (*uninit)(struct sspt_ip *); + int (*reg)(struct sspt_ip *); + void (*unreg)(struct sspt_ip *, int); + struct uprobe *(*get_uprobe)(struct sspt_ip *); int (*copy)(struct probe_info *, const struct probe_info *); void (*cleanup)(struct probe_info *); }; diff --git a/us_manager/probes/use_probes.h b/us_manager/probes/use_probes.h index 294742f..a925194 100644 --- a/us_manager/probes/use_probes.h +++ b/us_manager/probes/use_probes.h @@ -3,13 +3,13 @@ #include "probes.h" -struct us_ip; +struct sspt_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); +void probe_info_init(enum probe_t type, struct sspt_ip *ip); +void probe_info_uninit(enum probe_t type, struct sspt_ip *ip); +int probe_info_register(enum probe_t type, struct sspt_ip *ip); +void probe_info_unregister(enum probe_t type, struct sspt_ip *ip, int disarm); +struct uprobe *probe_info_get_uprobe(enum probe_t type, struct sspt_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/sspt.h b/us_manager/sspt/sspt.h index eadf5e5..bc8b6f5 100644 --- a/us_manager/sspt/sspt.h +++ b/us_manager/sspt/sspt.h @@ -25,7 +25,7 @@ * */ -#include "ip.h" +#include "sspt_ip.h" #include "sspt_page.h" #include "sspt_file.h" #include "sspt_proc.h" @@ -46,7 +46,7 @@ static inline int check_vma(struct vm_area_struct *vma) !(vma->vm_flags & (VM_READ | VM_MAYREAD))); } -static inline int sspt_register_usprobe(struct us_ip *ip) +static inline int sspt_register_usprobe(struct sspt_ip *ip) { int ret; struct uprobe *up = NULL; @@ -78,7 +78,7 @@ static inline int sspt_register_usprobe(struct us_ip *ip) } static inline int sspt_unregister_usprobe(struct task_struct *task, - struct us_ip *ip, + struct sspt_ip *ip, enum US_FLAGS flag) { struct uprobe *up = NULL; diff --git a/us_manager/sspt/sspt_debug.h b/us_manager/sspt/sspt_debug.h index 1a1a63e..5a22b31 100644 --- a/us_manager/sspt/sspt_debug.h +++ b/us_manager/sspt/sspt_debug.h @@ -40,7 +40,7 @@ static inline void print_retprobe(struct uretprobe *rp) (unsigned long)rp->handler); } -static inline void print_ip(struct us_ip *ip, int i) +static inline void print_ip(struct sspt_ip *ip, int i) { if (ip->desc->type == SWAP_RETPROBE) { struct uretprobe *rp = &ip->retprobe; @@ -55,17 +55,17 @@ static inline void print_ip(struct us_ip *ip, int i) static inline void print_page_probes(const struct sspt_page *page) { int i = 0; - struct us_ip *ip; + struct sspt_ip *ip; printk(KERN_INFO "### offset=%lx\n", page->offset); printk(KERN_INFO "### no install:\n"); - list_for_each_entry(ip, &page->ip_list_no_inst, list) { + list_for_each_entry(ip, &page->ip_list.not_inst, list) { print_ip(ip, i); ++i; } printk(KERN_INFO "### install:\n"); - list_for_each_entry(ip, &page->ip_list_inst, list) { + list_for_each_entry(ip, &page->ip_list.inst, list) { print_ip(ip, i); ++i; } @@ -86,7 +86,7 @@ static inline void print_file_probes(const struct sspt_file *file) return; } - table_size = (1 << file->page_probes_hash_bits); + table_size = (1 << file->htable.bits); name = (file->dentry) ? file->dentry->d_iname : NA; printk(KERN_INFO "### print_file_probes: path=%s, d_iname=%s, " @@ -94,7 +94,7 @@ static inline void print_file_probes(const struct sspt_file *file) file->dentry->d_iname, name, table_size, file->vm_start); for (i = 0; i < table_size; ++i) { - head = &file->page_probes_table[i]; + head = &file->htable.heads[i]; swap_hlist_for_each_entry_rcu(page, node, head, hlist) { print_page_probes(page); } @@ -106,37 +106,11 @@ static inline void print_proc_probes(const struct sspt_proc *proc) struct sspt_file *file; printk(KERN_INFO "### print_proc_probes\n"); - list_for_each_entry(file, &proc->file_list, list) { + list_for_each_entry(file, &proc->file_head, list) { print_file_probes(file); } printk(KERN_INFO "### print_proc_probes\n"); } -/* -static inline void print_inst_us_proc(const inst_us_proc_t *task_inst_info) -{ - int i; - int cnt = task_inst_info->libs_count; - printk( "### BUNDLE PRINT START ###\n"); - printk(KERN_INFO "\n### BUNDLE PRINT START ###\n"); - printk(KERN_INFO "### task_inst_info.libs_count=%d\n", cnt); - - for (i = 0; i < cnt; ++i) { - int j; - - us_proc_lib_t *lib = &task_inst_info->p_libs[i]; - int cnt_j = lib->ips_count; - char *path = lib->path; - printk(KERN_INFO "### path=%s, cnt_j=%d\n", path, cnt_j); - - for (j = 0; j < cnt_j; ++j) { - us_proc_ip_t *ips = &lib->p_ips[j]; - unsigned long offset = ips->offset; - printk(KERN_INFO "### offset=%lx\n", offset); - } - } - printk(KERN_INFO "### BUNDLE PRINT END ###\n"); -} -*/ #endif /* __SSPT_DEBUG__ */ diff --git a/us_manager/sspt/sspt_file.c b/us_manager/sspt/sspt_file.c index e017a67..2ad0b8a 100644 --- a/us_manager/sspt/sspt_file.c +++ b/us_manager/sspt/sspt_file.c @@ -43,6 +43,22 @@ static int calculation_hash_bits(int cnt) return bits; } +static unsigned long htable_size(const struct sspt_file *file) +{ + return 1 << file->htable.bits; +} + +static struct hlist_head *htable_head_by_key(const struct sspt_file *file, + unsigned long offset) +{ + return &file->htable.heads[hash_ptr((void *)offset, file->htable.bits)]; +} + +static struct hlist_head *htable_head_by_idx(const struct sspt_file *file, + unsigned long idx) +{ + return &file->htable.heads[idx]; +} /** * @brief Create sspt_file struct * @@ -53,6 +69,7 @@ static int calculation_hash_bits(int cnt) struct sspt_file *sspt_file_create(struct dentry *dentry, int page_cnt) { int i, table_size; + struct hlist_head *heads; struct sspt_file *obj = kmalloc(sizeof(*obj), GFP_ATOMIC); if (obj == NULL) @@ -65,19 +82,17 @@ struct sspt_file *sspt_file_create(struct dentry *dentry, int page_cnt) obj->vm_start = 0; obj->vm_end = 0; - obj->page_probes_hash_bits = calculation_hash_bits(page_cnt); - table_size = (1 << obj->page_probes_hash_bits); - - obj->page_probes_table = - kmalloc(sizeof(*obj->page_probes_table)*table_size, - GFP_ATOMIC); + obj->htable.bits = calculation_hash_bits(page_cnt); + table_size = htable_size(obj); - if (obj->page_probes_table == NULL) + heads = kmalloc(sizeof(*obj->htable.heads) * table_size, GFP_ATOMIC); + if (heads == NULL) goto err; for (i = 0; i < table_size; ++i) - INIT_HLIST_HEAD(&obj->page_probes_table[i]); + INIT_HLIST_HEAD(&heads[i]); + obj->htable.heads = heads; return obj; err: @@ -95,40 +110,35 @@ void sspt_file_free(struct sspt_file *file) { struct hlist_head *head; struct sspt_page *page; - int i, table_size = (1 << file->page_probes_hash_bits); + int i, table_size = htable_size(file); struct hlist_node *n; DECLARE_NODE_PTR_FOR_HLIST(p); for (i = 0; i < table_size; ++i) { - head = &file->page_probes_table[i]; + head = htable_head_by_idx(file, i); swap_hlist_for_each_entry_safe(page, p, n, head, hlist) { hlist_del(&page->hlist); sspt_page_free(page); } } - kfree(file->page_probes_table); + kfree(file->htable.heads); kfree(file); } static void sspt_add_page(struct sspt_file *file, struct sspt_page *page) { page->file = file; - hlist_add_head(&page->hlist, - &file->page_probes_table[hash_ptr( - (void *)page->offset, - file->page_probes_hash_bits)]); + hlist_add_head(&page->hlist, htable_head_by_key(file, page->offset)); } static struct sspt_page *sspt_find_page(struct sspt_file *file, unsigned long offset) { - struct hlist_head *head; + struct hlist_head *head = htable_head_by_key(file, offset); struct sspt_page *page; DECLARE_NODE_PTR_FOR_HLIST(node); - head = &file->page_probes_table[hash_ptr((void *)offset, - file->page_probes_hash_bits)]; swap_hlist_for_each_entry(page, node, head, hlist) { if (page->offset == offset) return page; @@ -191,7 +201,7 @@ void sspt_file_add_ip(struct sspt_file *file, struct img_ip *img_ip) { unsigned long offset = 0; struct sspt_page *page = NULL; - struct us_ip *ip = NULL; + struct sspt_ip *ip = NULL; offset = img_ip->addr & PAGE_MASK; page = sspt_find_page_or_new(file, offset); @@ -199,7 +209,7 @@ void sspt_file_add_ip(struct sspt_file *file, struct img_ip *img_ip) return; /* FIXME: delete ip */ - ip = create_ip(img_ip); + ip = sspt_ip_create(img_ip); if (!ip) return; @@ -208,51 +218,22 @@ void sspt_file_add_ip(struct sspt_file *file, struct img_ip *img_ip) } void sspt_file_on_each_ip(struct sspt_file *file, - void (*func)(struct us_ip *, void *), void *data) + void (*func)(struct sspt_ip *, void *), void *data) { int i; - const int table_size = (1 << file->page_probes_hash_bits); + const int table_size = htable_size(file); struct sspt_page *page; struct hlist_head *head; DECLARE_NODE_PTR_FOR_HLIST(node); for (i = 0; i < table_size; ++i) { - head = &file->page_probes_table[i]; + head = htable_head_by_idx(file, i); swap_hlist_for_each_entry(page, node, head, hlist) sspt_page_on_each_ip(page, func, data); } } /** - * @brief Get sspt_page from sspt_file (look) - * - * @param file Pointer to the sspt_file struct - * @param offset_addr File offset - * @return Pointer to the sspt_page struct - */ -struct sspt_page *sspt_get_page(struct sspt_file *file, - unsigned long offset_addr) -{ - unsigned long offset = offset_addr & PAGE_MASK; - struct sspt_page *page = sspt_find_page_or_new(file, offset); - - spin_lock(&page->lock); - - return page; -} - -/** - * @brief Put sspt_page (unlook) - * - * @param file Pointer to the sspt_page struct - * @return void - */ -void sspt_put_page(struct sspt_page *page) -{ - spin_unlock(&page->lock); -} - -/** * @brief Check install sspt_file (legacy code, it is need remove) * * @param file Pointer to the sspt_file struct @@ -268,9 +249,9 @@ int sspt_file_check_install_pages(struct sspt_file *file) struct hlist_node *tmp; DECLARE_NODE_PTR_FOR_HLIST(node); - table_size = (1 << file->page_probes_hash_bits); + table_size = htable_size(file); for (i = 0; i < table_size; ++i) { - head = &file->page_probes_table[i]; + head = htable_head_by_idx(file, i); swap_hlist_for_each_entry_safe(page, node, tmp, head, hlist) { if (sspt_page_is_installed(page)) return 1; @@ -290,13 +271,13 @@ void sspt_file_install(struct sspt_file *file) { struct sspt_page *page = NULL; struct hlist_head *head = NULL; - int i, table_size = (1 << file->page_probes_hash_bits); + int i, table_size = htable_size(file); unsigned long page_addr; struct mm_struct *mm; DECLARE_NODE_PTR_FOR_HLIST(node); for (i = 0; i < table_size; ++i) { - head = &file->page_probes_table[i]; + head = htable_head_by_idx(file, i); swap_hlist_for_each_entry_rcu(page, node, head, hlist) { page_addr = file->vm_start + page->offset; if (page_addr < file->vm_start || @@ -323,14 +304,14 @@ int sspt_file_uninstall(struct sspt_file *file, enum US_FLAGS flag) { int i, err = 0; - int table_size = (1 << file->page_probes_hash_bits); + int table_size = htable_size(file); struct sspt_page *page; struct hlist_head *head; struct hlist_node *tmp; DECLARE_NODE_PTR_FOR_HLIST(node); for (i = 0; i < table_size; ++i) { - head = &file->page_probes_table[i]; + head = htable_head_by_idx(file, i); swap_hlist_for_each_entry_safe(page, node, tmp, head, hlist) { err = sspt_unregister_page(page, flag, task); if (err != 0) { diff --git a/us_manager/sspt/sspt_file.h b/us_manager/sspt/sspt_file.h index 8e92279..3bda6ce 100644 --- a/us_manager/sspt/sspt_file.h +++ b/us_manager/sspt/sspt_file.h @@ -24,7 +24,7 @@ * Copyright (C) Samsung Electronics, 2013 */ -#include "ip.h" +#include "sspt_ip.h" #include enum US_FLAGS; @@ -35,16 +35,20 @@ struct vm_area_struct; * @breaf Image of file for specified process */ struct sspt_file { + /* sspt_proc */ struct list_head list; /**< For sspt_proc */ struct sspt_proc *proc; /**< Pointer to the proc (parent) */ + + /* sspt_page */ + struct { + unsigned long bits; /**< Hash-table size */ + struct hlist_head *heads; /**< Heads for pages */ + } htable; + struct dentry *dentry; /**< Dentry of file */ unsigned long vm_start; /**< VM start */ unsigned long vm_end; /**< VM end */ - - unsigned long page_probes_hash_bits; /**< Hash-table size */ - struct hlist_head *page_probes_table; /**< Hash-table for pages */ - - unsigned loaded:1; /**< Flag of loading */ + unsigned loaded:1; /**< Flag of loading */ }; @@ -56,11 +60,7 @@ struct sspt_page *sspt_find_page_mapped(struct sspt_file *file, void sspt_file_add_ip(struct sspt_file *file, struct img_ip *img_ip); void sspt_file_on_each_ip(struct sspt_file *file, - void (*func)(struct us_ip *, void *), void *data); - -struct sspt_page *sspt_get_page(struct sspt_file *file, - unsigned long offset_addr); -void sspt_put_page(struct sspt_page *page); + void (*func)(struct sspt_ip *, void *), void *data); int sspt_file_check_install_pages(struct sspt_file *file); void sspt_file_install(struct sspt_file *file); diff --git a/us_manager/sspt/ip.c b/us_manager/sspt/sspt_ip.c similarity index 92% rename from us_manager/sspt/ip.c rename to us_manager/sspt/sspt_ip.c index 624ddcf..5f116b0 100644 --- a/us_manager/sspt/ip.c +++ b/us_manager/sspt/sspt_ip.c @@ -24,7 +24,7 @@ #include #include -#include "ip.h" +#include "sspt_ip.h" #include "sspt_page.h" #include "sspt_file.h" #include @@ -39,9 +39,9 @@ * @param page Pointer to the parent sspt_page struct * @return Pointer to the created us_ip struct */ -struct us_ip *create_ip(struct img_ip *img_ip) +struct sspt_ip *sspt_ip_create(struct img_ip *img_ip) { - struct us_ip *ip; + struct sspt_ip *ip; ip = kmalloc(sizeof(*ip), GFP_ATOMIC); if (!ip) @@ -52,7 +52,7 @@ struct us_ip *create_ip(struct img_ip *img_ip) INIT_LIST_HEAD(&ip->img_list); ip->offset = img_ip->addr; ip->desc = img_ip->desc; - ip->iip = img_ip; + ip->img_ip = img_ip; list_add(&ip->img_list, &img_ip->ihead); return ip; @@ -64,7 +64,7 @@ struct us_ip *create_ip(struct img_ip *img_ip) * @param ip remove object * @return Void */ -void free_ip(struct us_ip *ip) +void sspt_ip_free(struct sspt_ip *ip) { if (!list_empty(&ip->img_list)) list_del(&ip->img_list); diff --git a/us_manager/sspt/ip.h b/us_manager/sspt/sspt_ip.h similarity index 81% rename from us_manager/sspt/ip.h rename to us_manager/sspt/sspt_ip.h index 22f2760..14954b8 100644 --- a/us_manager/sspt/ip.h +++ b/us_manager/sspt/sspt_ip.h @@ -1,5 +1,5 @@ -#ifndef __IP__ -#define __IP__ +#ifndef _SSPT_IP +#define _SSPT_IP /** * @file us_manager/sspt/ip.h @@ -31,28 +31,32 @@ struct sspt_page; /** - * @struct us_ip + * @struct sspt_ip * @breaf Image of instrumentation pointer for specified process */ -struct us_ip { +struct sspt_ip { + /* sspt_page */ struct list_head list; /**< For sspt_page */ struct sspt_page *page; /**< Pointer on the page (parent) */ - struct probe_desc *desc; /**< Probe's data */ - struct img_ip *iip; - struct list_head img_list; + + /* img_ip */ + struct img_ip *img_ip; /**< Pointer on the img_ip (parent) */ + struct list_head img_list; /**< For img_ip */ unsigned long orig_addr; /**< Function address */ unsigned long offset; /**< Page offset */ + struct probe_desc *desc; /**< Probe's data */ + union { struct uretprobe retprobe; struct uprobe uprobe; }; }; -#define to_us_ip(rp) container_of(rp, struct us_ip, retprobe) -struct us_ip *create_ip(struct img_ip *img_ip); -void free_ip(struct us_ip *ip); +struct sspt_ip *sspt_ip_create(struct img_ip *img_ip); +void sspt_ip_free(struct sspt_ip *ip); + -#endif /* __IP__ */ +#endif /* _SSPT_IP */ diff --git a/us_manager/sspt/sspt_page.c b/us_manager/sspt/sspt_page.c index db8411e..54971f9 100644 --- a/us_manager/sspt/sspt_page.c +++ b/us_manager/sspt/sspt_page.c @@ -25,7 +25,7 @@ #include "sspt.h" #include "sspt_page.h" #include "sspt_file.h" -#include "ip.h" +#include "sspt_ip.h" #include #include #include @@ -40,10 +40,10 @@ struct sspt_page *sspt_page_create(unsigned long offset) { struct sspt_page *obj = kmalloc(sizeof(*obj), GFP_ATOMIC); if (obj) { - INIT_LIST_HEAD(&obj->ip_list_inst); - INIT_LIST_HEAD(&obj->ip_list_no_inst); + INIT_LIST_HEAD(&obj->ip_list.inst); + INIT_LIST_HEAD(&obj->ip_list.not_inst); obj->offset = offset; - spin_lock_init(&obj->lock); + spin_lock_init(&obj->ip_list.lock); obj->file = NULL; INIT_HLIST_NODE(&obj->hlist); } @@ -59,27 +59,27 @@ struct sspt_page *sspt_page_create(unsigned long offset) */ void sspt_page_free(struct sspt_page *page) { - struct us_ip *ip, *n; + struct sspt_ip *ip, *n; - list_for_each_entry_safe(ip, n, &page->ip_list_inst, list) { + list_for_each_entry_safe(ip, n, &page->ip_list.inst, list) { list_del(&ip->list); - free_ip(ip); + sspt_ip_free(ip); } - list_for_each_entry_safe(ip, n, &page->ip_list_no_inst, list) { + list_for_each_entry_safe(ip, n, &page->ip_list.not_inst, list) { list_del(&ip->list); - free_ip(ip); + sspt_ip_free(ip); } kfree(page); } -static void sspt_list_add_ip(struct sspt_page *page, struct us_ip *ip) +static void sspt_list_add_ip(struct sspt_page *page, struct sspt_ip *ip) { - list_add(&ip->list, &page->ip_list_no_inst); + list_add(&ip->list, &page->ip_list.not_inst); } -static void sspt_list_del_ip(struct us_ip *ip) +static void sspt_list_del_ip(struct sspt_ip *ip) { list_del(&ip->list); } @@ -91,7 +91,7 @@ static void sspt_list_del_ip(struct us_ip *ip) * @param ip Pointer to the us_ip struct * @return Void */ -void sspt_add_ip(struct sspt_page *page, struct us_ip *ip) +void sspt_add_ip(struct sspt_page *page, struct sspt_ip *ip) { ip->offset &= ~PAGE_MASK; ip->page = page; @@ -104,10 +104,10 @@ void sspt_add_ip(struct sspt_page *page, struct us_ip *ip) * @param ip Pointer to the us_ip struct * @return Void */ -void sspt_del_ip(struct us_ip *ip) +void sspt_del_ip(struct sspt_ip *ip) { sspt_list_del_ip(ip); - free_ip(ip); + sspt_ip_free(ip); } /** @@ -122,9 +122,9 @@ int sspt_page_is_installed(struct sspt_page *page) { int empty; - spin_lock(&page->lock); - empty = list_empty(&page->ip_list_inst); - spin_unlock(&page->lock); + spin_lock(&page->ip_list.lock); + empty = list_empty(&page->ip_list.inst); + spin_unlock(&page->ip_list.lock); return !empty; } @@ -139,11 +139,11 @@ int sspt_page_is_installed(struct sspt_page *page) int sspt_register_page(struct sspt_page *page, struct sspt_file *file) { int err = 0; - struct us_ip *ip, *n; + struct sspt_ip *ip, *n; struct list_head ip_list_tmp; - spin_lock(&page->lock); - if (list_empty(&page->ip_list_no_inst)) { + spin_lock(&page->ip_list.lock); + if (list_empty(&page->ip_list.not_inst)) { struct task_struct *task = page->file->proc->task; printk(KERN_INFO "page %lx in %s task[tgid=%u, pid=%u] " @@ -154,8 +154,8 @@ int sspt_register_page(struct sspt_page *page, struct sspt_file *file) } INIT_LIST_HEAD(&ip_list_tmp); - list_replace_init(&page->ip_list_no_inst, &ip_list_tmp); - spin_unlock(&page->lock); + list_replace_init(&page->ip_list.not_inst, &ip_list_tmp); + spin_unlock(&page->ip_list.lock); list_for_each_entry_safe(ip, n, &ip_list_tmp, list) { /* set virtual address */ @@ -164,16 +164,16 @@ int sspt_register_page(struct sspt_page *page, struct sspt_file *file) err = sspt_register_usprobe(ip); if (err) { list_del(&ip->list); - free_ip(ip); + sspt_ip_free(ip); continue; } } - spin_lock(&page->lock); - list_splice(&ip_list_tmp, &page->ip_list_inst); + spin_lock(&page->ip_list.lock); + list_splice(&ip_list_tmp, &page->ip_list.inst); unlock: - spin_unlock(&page->lock); + spin_unlock(&page->ip_list.lock); return 0; } @@ -191,19 +191,19 @@ int sspt_unregister_page(struct sspt_page *page, struct task_struct *task) { int err = 0; - struct us_ip *ip; + struct sspt_ip *ip; struct list_head ip_list_tmp, *head; - spin_lock(&page->lock); - if (list_empty(&page->ip_list_inst)) { - spin_unlock(&page->lock); + spin_lock(&page->ip_list.lock); + if (list_empty(&page->ip_list.inst)) { + spin_unlock(&page->ip_list.lock); return 0; } INIT_LIST_HEAD(&ip_list_tmp); - list_replace_init(&page->ip_list_inst, &ip_list_tmp); + list_replace_init(&page->ip_list.inst, &ip_list_tmp); - spin_unlock(&page->lock); + spin_unlock(&page->ip_list.lock); list_for_each_entry(ip, &ip_list_tmp, list) { err = sspt_unregister_usprobe(task, ip, flag); @@ -214,24 +214,24 @@ int sspt_unregister_page(struct sspt_page *page, } head = (flag == US_DISARM) ? - &page->ip_list_inst : &page->ip_list_no_inst; + &page->ip_list.inst : &page->ip_list.not_inst; - spin_lock(&page->lock); + spin_lock(&page->ip_list.lock); list_splice(&ip_list_tmp, head); - spin_unlock(&page->lock); + spin_unlock(&page->ip_list.lock); return err; } void sspt_page_on_each_ip(struct sspt_page *page, - void (*func)(struct us_ip *, void *), void *data) + void (*func)(struct sspt_ip *, void *), void *data) { - struct us_ip *ip; + struct sspt_ip *ip; - spin_lock(&page->lock); - list_for_each_entry(ip, &page->ip_list_inst, list) + spin_lock(&page->ip_list.lock); + list_for_each_entry(ip, &page->ip_list.inst, list) func(ip, data); - spin_unlock(&page->lock); + spin_unlock(&page->ip_list.lock); } diff --git a/us_manager/sspt/sspt_page.h b/us_manager/sspt/sspt_page.h index f06e536..837893b 100644 --- a/us_manager/sspt/sspt_page.h +++ b/us_manager/sspt/sspt_page.h @@ -27,7 +27,7 @@ #include #include -struct us_ip; +struct sspt_ip; struct sspt_file; struct task_struct; enum US_FLAGS; @@ -37,20 +37,25 @@ enum US_FLAGS; * @breaf Image of page for specified process */ struct sspt_page { - struct list_head ip_list_inst; /**< For installed ip */ - struct list_head ip_list_no_inst; /**< For don'tinstalled ip */ - unsigned long offset; /**< File offset */ - spinlock_t lock; /**< Lock page */ - - struct sspt_file *file; /**< Ptr to the file(parent)=*/ + /* sspt_file */ struct hlist_node hlist; /**< For sspt_file */ + struct sspt_file *file; /**< Ptr to the file (parent) */ + + /* sspt_ip */ + struct { + spinlock_t lock; /**< Lock page */ + struct list_head inst; /**< For installed ip */ + struct list_head not_inst; /**< For don'tinstalled ip */ + } ip_list; + + unsigned long offset; /**< File offset */ }; struct sspt_page *sspt_page_create(unsigned long offset); void sspt_page_free(struct sspt_page *page); -void sspt_add_ip(struct sspt_page *page, struct us_ip *ip); -void sspt_del_ip(struct us_ip *ip); +void sspt_add_ip(struct sspt_page *page, struct sspt_ip *ip); +void sspt_del_ip(struct sspt_ip *ip); int sspt_page_is_installed(struct sspt_page *page); @@ -61,6 +66,6 @@ int sspt_unregister_page(struct sspt_page *page, struct task_struct *task); void sspt_page_on_each_ip(struct sspt_page *page, - void (*func)(struct us_ip *, void *), void *data); + void (*func)(struct sspt_ip *, void *), void *data); #endif /* __SSPT_PAGE__ */ diff --git a/us_manager/sspt/sspt_proc.c b/us_manager/sspt/sspt_proc.c index 71d7f89..ad02a0e 100644 --- a/us_manager/sspt/sspt_proc.c +++ b/us_manager/sspt/sspt_proc.c @@ -105,7 +105,7 @@ struct sspt_proc *sspt_proc_create(struct task_struct *task) proc->tgid = task->tgid; proc->task = task->group_leader; proc->sm = create_sm_us(task); - INIT_LIST_HEAD(&proc->file_list); + INIT_LIST_HEAD(&proc->file_head); rwlock_init(&proc->filter_lock); INIT_LIST_HEAD(&proc->filter_list); atomic_set(&proc->usage, 1); @@ -133,7 +133,7 @@ void sspt_proc_cleanup(struct sspt_proc *proc) sspt_proc_del_all_filters(proc); - list_for_each_entry_safe(file, n, &proc->file_list, list) { + list_for_each_entry_safe(file, n, &proc->file_head, list) { list_del(&file->list); sspt_file_free(file); } @@ -267,7 +267,7 @@ void sspt_proc_free_all(void) static void sspt_proc_add_file(struct sspt_proc *proc, struct sspt_file *file) { - list_add(&file->list, &proc->file_list); + list_add(&file->list, &proc->file_head); file->proc = proc; } @@ -305,7 +305,7 @@ struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc, { struct sspt_file *file; - list_for_each_entry(file, &proc->file_list, list) { + list_for_each_entry(file, &proc->file_head, list) { if (dentry == file->dentry) return file; } @@ -382,7 +382,7 @@ int sspt_proc_uninstall(struct sspt_proc *proc, int err = 0; struct sspt_file *file; - list_for_each_entry_rcu(file, &proc->file_list, list) { + list_for_each_entry_rcu(file, &proc->file_head, list) { err = sspt_file_uninstall(file, task, flag); if (err != 0) { printk(KERN_INFO "ERROR sspt_proc_uninstall: err=%d\n", @@ -419,7 +419,7 @@ int sspt_proc_get_files_by_region(struct sspt_proc *proc, struct sspt_file *file, *n; unsigned long end = start + len; - list_for_each_entry_safe(file, n, &proc->file_list, list) { + list_for_each_entry_safe(file, n, &proc->file_head, list) { if (intersection(file->vm_start, file->vm_end, start, end)) { ret = 1; list_move(&file->list, head); @@ -438,7 +438,7 @@ int sspt_proc_get_files_by_region(struct sspt_proc *proc, */ void sspt_proc_insert_files(struct sspt_proc *proc, struct list_head *head) { - list_splice(head, &proc->file_list); + list_splice(head, &proc->file_head); } /** @@ -525,11 +525,11 @@ void sspt_proc_on_each_filter(struct sspt_proc *proc, } void sspt_proc_on_each_ip(struct sspt_proc *proc, - void (*func)(struct us_ip *, void *), void *data) + void (*func)(struct sspt_ip *, void *), void *data) { struct sspt_file *file; - list_for_each_entry(file, &proc->file_list, list) + list_for_each_entry(file, &proc->file_head, list) sspt_file_on_each_ip(file, func, data); } diff --git a/us_manager/sspt/sspt_proc.h b/us_manager/sspt/sspt_proc.h index aecf40d..77b6438 100644 --- a/us_manager/sspt/sspt_proc.h +++ b/us_manager/sspt/sspt_proc.h @@ -31,7 +31,7 @@ struct slot_manager; struct task_struct; struct pf_group; struct sspt_filter; -struct us_ip; +struct sspt_ip; /** Flags for sspt_*_uninstall() */ enum US_FLAGS { @@ -46,20 +46,25 @@ enum US_FLAGS { */ struct sspt_proc { struct list_head list; /**< For global process list */ + + /* sspt_file */ + struct list_head file_head; /**< For sspt_file */ + pid_t tgid; /**< Thread group ID */ struct task_struct *task; /**< Ptr to the task */ struct mm_struct *__mm; struct task_struct *__task; - unsigned long r_state_addr; /**< address of r_state */ struct slot_manager *sm; /**< Ptr to the manager slot */ - struct list_head file_list; /**< For sspt_file */ + rwlock_t filter_lock; struct list_head filter_list; /**< Filter list */ + unsigned first_install:1; /**< Install flag */ struct sspt_feature *feature; /**< Ptr to the feature */ atomic_t usage; /* FIXME: for preload (remove those fields) */ + unsigned long r_state_addr; /**< address of r_state */ void *private_data; /**< Process private data */ }; @@ -115,7 +120,7 @@ void sspt_proc_on_each_filter(struct sspt_proc *proc, void *data); void sspt_proc_on_each_ip(struct sspt_proc *proc, - void (*func)(struct us_ip *, void *), void *data); + void (*func)(struct sspt_ip *, void *), void *data); bool sspt_proc_is_send_event(struct sspt_proc *proc); diff --git a/webprobe/webprobe.c b/webprobe/webprobe.c index 9f4e983..3082114 100644 --- a/webprobe/webprobe.c +++ b/webprobe/webprobe.c @@ -29,7 +29,7 @@ #include -#include +#include #include #include #include @@ -59,17 +59,17 @@ static void webprobe_cleanup(struct probe_info *probe_i) { } -static struct uprobe *webprobe_get_uprobe(struct us_ip *ip) +static struct uprobe *webprobe_get_uprobe(struct sspt_ip *ip) { return &ip->retprobe.up; } -static int webprobe_register_probe(struct us_ip *ip) +static int webprobe_register_probe(struct sspt_ip *ip) { return swap_register_uretprobe(&ip->retprobe); } -static void webprobe_unregister_probe(struct us_ip *ip, int disarm) +static void webprobe_unregister_probe(struct sspt_ip *ip, int disarm) { if (ip->orig_addr == inspserver_addr_local) web_func_inst_remove(INSPSERVER_START); @@ -85,14 +85,14 @@ static int web_entry_handler(struct uretprobe_instance *ri, struct pt_regs *regs) { struct uretprobe *rp = ri->rp; - struct us_ip *ip; + struct sspt_ip *ip; unsigned long vaddr, page_vaddr; struct vm_area_struct *vma; if (rp == NULL) return 0; - ip = container_of(rp, struct us_ip, retprobe); + ip = container_of(rp, struct sspt_ip, retprobe); vaddr = (unsigned long)ip->orig_addr; page_vaddr = vaddr & PAGE_MASK; @@ -119,14 +119,14 @@ static int web_entry_handler(struct uretprobe_instance *ri, static int web_ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs) { struct uretprobe *rp = ri->rp; - struct us_ip *ip; + struct sspt_ip *ip; unsigned long vaddr, page_vaddr; struct vm_area_struct *vma; if (rp == NULL) return 0; - ip = container_of(rp, struct us_ip, retprobe); + ip = container_of(rp, struct sspt_ip, retprobe); vaddr = (unsigned long)ip->orig_addr; page_vaddr = vaddr & PAGE_MASK; @@ -145,14 +145,14 @@ static int web_ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs) return 0; } -static void webprobe_init(struct us_ip *ip) +static void webprobe_init(struct sspt_ip *ip) { ip->retprobe.entry_handler = web_entry_handler; ip->retprobe.handler = web_ret_handler; ip->retprobe.maxactive = 0; } -static void webprobe_uninit(struct us_ip *ip) +static void webprobe_uninit(struct sspt_ip *ip) { webprobe_cleanup(&ip->desc->info); }