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;
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)
/* 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
};
}
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;
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);
}
* @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;
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;
* @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;
}
* @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;
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;
}
* @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;
}
* @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;
}
* @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;
}
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;
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:
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:
goto free_func_inst;
}
+ fi->p_desc.type = type;
return fi;
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);
*/
struct func_inst_data {
u64 addr; /**< Function address. */
- struct probe_info probe_i; /**< Probe info. */
+ struct probe_desc p_desc; /**< Probe info. */
};
/**
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);
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;
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;
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;
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;
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)) {
{
preload_module_uprobe_exit(ip);
- preload_info_cleanup(ip->info);
+ preload_info_cleanup(&ip->desc->info);
}
static struct probe_iface preload_iface = {
{
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 = {
{
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 = {
{
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 = {
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);
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);
}
static void retprobe_uninit(struct us_ip *ip)
{
- retprobe_cleanup(ip->info);
+ retprobe_cleanup(&ip->desc->info);
}
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' */
* @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;
return 0;
}
- ip = create_img_ip(addr, probe_i);
+ ip = create_img_ip(addr, pd);
img_add_ip_by_list(file, ip);
return 0;
#include <linux/types.h>
-struct probe_info;
+struct probe_desc;
/**
* @struct img_file
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);
#include "img_ip.h"
#include <us_manager/probes/use_probes.h>
+#include <us_manager/sspt/ip.h>
#include <linux/slab.h>
/**
* @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;
}
*/
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);
}
/* 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 */
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 */
* @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;
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;
}
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);
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);
}
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);
* @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);
struct dentry;
struct pf_group;
struct sspt_proc;
-struct probe_info;
+struct probe_desc;
struct pfg_msg_cb {
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);
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);
}
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;
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
*/
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);
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);
} 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;
};
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,
#include <linux/errno.h>
#include <linux/module.h>
-
-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
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;
}
* @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);
}
/**
* @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);
}
/**
* @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);
}
/**
* @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);
}
/**
* @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);
}
/**
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;
}
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;
}
#define __PROBES_H__
#include <linux/types.h>
+#include <uprobe/swap_uprobes.h>
#include <preload/preload_probe.h> /* TODO Remove */
#include <retprobe/retprobe.h> /* TODO Remove */
/* 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;
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__ */
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);
#include "sspt_page.h"
#include "sspt_file.h"
#include <us_manager/probes/use_probes.h>
+#include <us_manager/img/img_ip.h>
/**
* @brief Create us_ip struct
* @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;
}
*/
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);
}
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 */
#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__ */
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");
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;
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);
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",
#include <linux/hash.h>
#include <linux/sched.h>
#include <kprobe/swap_kprobes_deps.h>
+#include <us_manager/probes/probes.h>
+#include <us_manager/img/img_ip.h>
static int calculation_hash_bits(int cnt)
{
* @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);
}
/**
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);
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);
}
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
*
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,
static void webprobe_uninit(struct us_ip *ip)
{
- webprobe_cleanup(ip->info);
+ webprobe_cleanup(&ip->desc->info);
}
#include <us_manager/pf/pf_group.h>
#include <us_manager/probes/probes.h>
+#include <us_manager/probes/probe_info_new.h>
#include "webprobe_prof.h"
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);
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 \
}
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);
/*
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);
/*
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 *));
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);
/*
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);
/*
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 *));
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[] = {