}
/* FBI probe interfaces */
-void fbi_probe_cleanup(struct probe_info *probe_i)
-{
- uint8_t i;
- struct fbi_info *fbi_i = &(probe_i->fbi_i);
-
- for (i = 0; i != fbi_i->var_count; i++) {
- if (fbi_i->vars[i].steps != NULL) {
- if (fbi_i->vars[i].steps != NULL)
- kfree(fbi_i->vars[i].steps);
- fbi_i->vars[i].steps = NULL;
- fbi_i->vars[i].steps_count = 0;
- }
- }
-
- kfree(fbi_i->vars);
- fbi_i->vars = NULL;
-}
-
void fbi_probe_init(struct sspt_ip *ip)
{
ip->uprobe.pre_handler = (uprobe_pre_handler_t)fbi_probe_handler;
return &ip->uprobe;
}
-int fbi_probe_copy(struct probe_info *dest, const struct probe_info *source)
-{
- uint8_t steps_count;
- size_t steps_size;
- size_t vars_size;
- struct fbi_var_data *vars;
- struct fbi_step *steps_source;
- struct fbi_step *steps_dest = NULL;
- uint8_t i, n;
- int ret = 0;
-
- memcpy(dest, source, sizeof(*source));
-
- vars_size = source->fbi_i.var_count * sizeof(*source->fbi_i.vars);
- vars = kmalloc(vars_size, GFP_KERNEL);
- if (vars == NULL)
- return -ENOMEM;
-
- memcpy(vars, source->fbi_i.vars, vars_size);
-
- for (i = 0; i != source->fbi_i.var_count; i++) {
- steps_dest = NULL;
- steps_count = vars[i].steps_count;
- steps_size = sizeof(*steps_source) * steps_count;
- steps_source = vars[i].steps;
-
- if (steps_size != 0 && steps_source != NULL) {
- steps_dest = kmalloc(steps_size, GFP_KERNEL);
- if (steps_dest == NULL) {
- print_err("can not alloc data\n");
- n = i;
- ret = -ENOMEM;
- goto err;
- }
-
- memcpy(steps_dest, steps_source, steps_size);
- }
- vars[i].steps = steps_dest;
- }
-
- dest->fbi_i.vars = vars;
-
- return ret;
-err:
- for (i = 0; i < n; i++)
- kfree(vars[i].steps);
- kfree(vars);
- return ret;
-}
-
/* Register */
static struct probe_iface fbi_probe_iface = {
.init = fbi_probe_init,
.reg = fbi_probe_register_probe,
.unreg = fbi_probe_unregister_probe,
.get_uprobe = fbi_probe_get_uprobe,
- .copy = fbi_probe_copy,
- .cleanup = fbi_probe_cleanup
};
static int fbiprobe_init(void)
#include "preload.h"
#include "preload_module.h"
-static int preload_info_copy(struct probe_info *dest,
- const struct probe_info *source)
-{
- memcpy(dest, source, sizeof(*source));
-
- return 0;
-}
-
-static void preload_info_cleanup(struct probe_info *probe_i)
-{
-}
static struct uprobe *preload_get_uprobe(struct sspt_ip *ip)
{
static void preload_uninit(struct sspt_ip *ip)
{
pm_uprobe_exit(ip);
-
- preload_info_cleanup(&ip->desc->info);
}
static struct probe_iface preload_iface = {
.reg = preload_register_probe,
.unreg = preload_unregister_probe,
.get_uprobe = preload_get_uprobe,
- .copy = preload_info_copy,
- .cleanup = preload_info_cleanup
};
-static int get_caller_info_copy(struct probe_info *dest,
- const struct probe_info *source)
-{
- memcpy(dest, source, sizeof(*source));
-
- return 0;
-}
-
-static void get_caller_info_cleanup(struct probe_info *probe_i)
-{
-}
-
static struct uprobe *get_caller_get_uprobe(struct sspt_ip *ip)
{
return &ip->uprobe;
static void get_caller_uninit(struct sspt_ip *ip)
{
pm_get_caller_exit(ip);
-
- get_caller_info_cleanup(&ip->desc->info);
}
static struct probe_iface get_caller_iface = {
.reg = get_caller_register_probe,
.unreg = get_caller_unregister_probe,
.get_uprobe = get_caller_get_uprobe,
- .copy = get_caller_info_copy,
- .cleanup = get_caller_info_cleanup
};
static void get_call_type_init(struct sspt_ip *ip)
static void get_call_type_uninit(struct sspt_ip *ip)
{
pm_get_call_type_exit(ip);
-
- get_caller_info_cleanup(&ip->desc->info);
}
static struct probe_iface get_call_type_iface = {
.reg = get_caller_register_probe,
.unreg = get_caller_unregister_probe,
.get_uprobe = get_caller_get_uprobe,
- .copy = get_caller_info_copy,
- .cleanup = get_caller_info_cleanup
};
static void write_msg_init(struct sspt_ip *ip)
static void write_msg_uninit(struct sspt_ip *ip)
{
pm_write_msg_exit(ip);
-
- get_caller_info_cleanup(&ip->desc->info);
}
static struct probe_iface write_msg_iface = {
.reg = write_msg_reg,
.unreg = get_caller_unregister_probe,
.get_uprobe = get_caller_get_uprobe,
- .copy = get_caller_info_copy,
- .cleanup = get_caller_info_cleanup
};
int register_preload_probes(void)
#include "rp_msg.h"
-static int retprobe_copy(struct probe_info *dest,
- const struct probe_info *source)
-{
- size_t len;
-
- memcpy(dest, source, sizeof(*source));
-
- len = strlen(source->rp_i.args) + 1;
- dest->rp_i.args = kmalloc(len, GFP_ATOMIC);
- if (dest->rp_i.args == NULL)
- return -ENOMEM;
- memcpy(dest->rp_i.args, source->rp_i.args, len);
-
- return 0;
-}
-
-
-static void retprobe_cleanup(struct probe_info *probe_i)
-{
- kfree(probe_i->rp_i.args);
-}
-
-
-
static struct uprobe *retprobe_get_uprobe(struct sspt_ip *ip)
{
return &ip->retprobe.up;
.reg = retprobe_register_probe,
.unreg = retprobe_unregister_probe,
.get_uprobe = retprobe_get_uprobe,
- .copy = retprobe_copy,
- .cleanup = retprobe_cleanup
};
static int mod_init(void)
/*
* SWAP_NEW_UP
*/
-static int up_copy(struct probe_info *dst, const struct probe_info *src)
-{
- return 0;
-}
-
-static void up_cleanup(struct probe_info *probe_i)
-{
-}
-
static struct uprobe *up_get_uprobe(struct sspt_ip *ip)
{
return &ip->uprobe;
.reg = up_register_probe,
.unreg = up_unregister_probe,
.get_uprobe = up_get_uprobe,
- .copy = up_copy,
- .cleanup = up_cleanup
};
/*
* SWAP_NEW_URP
*/
-static int urp_copy(struct probe_info *dst, const struct probe_info *src)
-{
- return 0;
-}
-
-static void urp_cleanup(struct probe_info *probe_i)
-{
-}
-
static struct uprobe *urp_get_uprobe(struct sspt_ip *ip)
{
return &ip->retprobe.up;
.reg = urp_register_probe,
.unreg = urp_unregister_probe,
.get_uprobe = urp_get_uprobe,
- .copy = urp_copy,
- .cleanup = urp_cleanup
};
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 *);
};
int swap_register_probe_type(enum probe_t probe_type, struct probe_iface *pi);