struct list_head file_list;
};
-us_proc_ip_t *us_proc_ip_copy(const us_proc_ip_t *ip)
+struct us_ip *us_proc_ip_copy(const struct us_ip *ip)
{
- us_proc_ip_t *ip_out = kmalloc(sizeof(*ip_out), GFP_ATOMIC);
+ struct us_ip *ip_out = kmalloc(sizeof(*ip_out), GFP_ATOMIC);
if (ip_out == NULL) {
DPRINTF ("us_proc_ip_copy: No enough memory");
return NULL;
ip_out->flag_got = 0;
- ip_out->installed = 0;
INIT_LIST_HEAD(&ip_out->list);
return ip_out;
}
-us_proc_ip_t *us_proc_ips_copy(const us_proc_ip_t *ips, int cnt)
+struct us_ip *us_proc_ips_copy(const struct us_ip *ips, int cnt)
{
int i;
- us_proc_ip_t *ips_out =
- kmalloc (cnt * sizeof (us_proc_ip_t), GFP_ATOMIC);
+ struct us_ip *ips_out =
+ kmalloc(cnt * sizeof(*ips), GFP_ATOMIC);
if (!ips_out) {
DPRINTF ("No enough memory for copy_info->p_libs[i].p_ips");
return NULL;
}
- memcpy (ips_out, ips, cnt * sizeof (us_proc_ip_t));
+ memcpy(ips_out, ips, cnt * sizeof(*ips));
for (i = 0; i < cnt; ++i) {
- ips_out[i].installed = 0;
-
// jprobe
memset(&ips_out[i].jprobe, 0, sizeof(struct jprobe));
ips_out[i].jprobe.entry = ips[i].jprobe.entry;
static struct page_probes *page_p_copy(const struct page_probes *page_p)
{
- us_proc_ip_t *ip_in, *ip_out;
+ struct us_ip *ip_in, *ip_out;
struct page_probes *page_p_out = kmalloc(sizeof(*page_p), GFP_ATOMIC);
if (page_p_out) {
return page_p_out;
}
-static void page_p_add_ip(struct page_probes *page_p, us_proc_ip_t *ip)
+static void page_p_add_ip(struct page_probes *page_p, struct us_ip *ip)
{
ip->offset &= ~PAGE_MASK;
INIT_LIST_HEAD(&ip->list);
list_add(&ip->list, &page_p->ip_list);
}
-static us_proc_ip_t *page_p_find_ip(struct page_probes *page_p, unsigned long offset)
+static struct us_ip *page_p_find_ip(struct page_probes *page_p, unsigned long offset)
{
- us_proc_ip_t *ip;
+ struct us_ip *ip;
list_for_each_entry(ip, &page_p->ip_list, list) {
if (ip->offset == offset) {
}
// page_probes
-static void set_ip_kp_addr(us_proc_ip_t *ip, struct page_probes *page_p, const struct file_probes *file_p)
+static void set_ip_kp_addr(struct us_ip *ip, struct page_probes *page_p, const struct file_probes *file_p)
{
unsigned long addr = file_p->vm_start + page_p->offset + ip->offset;
ip->retprobe.kp.addr = ip->jprobe.kp.addr = addr;
static void page_p_set_all_kp_addr(struct page_probes *page_p, const struct file_probes *file_p)
{
- us_proc_ip_t *ip;
+ struct us_ip *ip;
unsigned long addr;
list_for_each_entry(ip, &page_p->ip_list, list) {
struct page_probes *page_p = file_p_find_page_p_or_new(file_p, offset);
// FIXME: ip
- us_proc_ip_t *ip = kmalloc(sizeof(*ip), GFP_ATOMIC);
+ struct us_ip *ip = kmalloc(sizeof(*ip), GFP_ATOMIC);
memset(ip, 0, sizeof(*ip));
INIT_LIST_HEAD(&ip->list);
return proc_p;
}
-static int register_usprobe_my(struct task_struct *task, us_proc_ip_t *ip)
+static int register_usprobe_my(struct task_struct *task, struct us_ip *ip)
{
- ip->installed = 0;
- ip->name = 0;
-
return register_usprobe(task, ip, 1);
}
-static int unregister_usprobe_my(struct task_struct *task, us_proc_ip_t *ip, enum US_FLAGS flag)
+static int unregister_usprobe_my(struct task_struct *task, struct us_ip *ip, enum US_FLAGS flag)
{
int err = 0;
static void print_page_probes(const struct page_probes *page_p)
{
int i = 0;
- us_proc_ip_t *ip;
+ struct us_ip *ip;
printk("### offset=%x\n", page_p->offset);
list_for_each_entry(ip, &page_p->ip_list, list) {
printk("### 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];
+ struct us_ip *ips = &lib->p_ips[j];
unsigned long offset = ips->offset;
printk("### offset=%x\n", offset);
}
unsigned flag_got:1;
} us_proc_ip_t;
+struct us_ip {
+ struct list_head list;
+
+ struct jprobe jprobe;
+ struct kretprobe retprobe;
+
+ unsigned long offset;
+ unsigned long got_addr;
+
+ unsigned flag_retprobe:1;
+ unsigned flag_got:1;
+};
+
typedef struct
{
int installed;
# warning ARCH_REG_VAL is not implemented for this architecture. FBI will work improperly or even crash!!!
#endif // ARCH
-unsigned long ujprobe_event_pre_handler (us_proc_ip_t * ip, struct pt_regs *regs);
+unsigned long ujprobe_event_pre_handler (struct us_ip *ip, struct pt_regs *regs);
void ujprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6);
-int uretprobe_event_handler (struct kretprobe_instance *probe, struct pt_regs *regs, us_proc_ip_t * ip);
+int uretprobe_event_handler (struct kretprobe_instance *probe, struct pt_regs *regs, struct us_ip *ip);
-static int register_usprobe(struct task_struct *task, us_proc_ip_t *ip, int atomic);
-static int unregister_usprobe(struct task_struct *task, us_proc_ip_t * ip, int atomic, int no_rp2);
+static int register_usprobe(struct task_struct *task, struct us_ip *ip, int atomic);
+static int unregister_usprobe(struct task_struct *task, struct us_ip *ip, int atomic, int no_rp2);
#include "new_dpf.h"
struct file_probes *file_p = proc_p_find_file_p_by_dentry(proc_p, name, dentry);
struct page_probes *page_p = get_page_p(file_p, offset_addr);
- us_proc_ip_t *ip = page_p_find_ip(page_p, offset_addr & ~PAGE_MASK);
+ struct us_ip *ip = page_p_find_ip(page_p, offset_addr & ~PAGE_MASK);
if (!file_p->loaded) {
set_mapping_file(file_p, proc_p, task, vma);
const struct task_struct *task)
{
int err = 0;
- us_proc_ip_t *ip;
+ struct us_ip *ip;
spin_lock(&page_p->lock);
struct page_probes *page_p, enum US_FLAGS flag)
{
int err = 0;
- us_proc_ip_t *ip;
+ struct us_ip *ip;
spin_lock(&page_p->lock);
if (!page_p_is_install(page_p)) {
}
-DEFINE_PER_CPU (us_proc_ip_t *, gpCurIp) = NULL;
+DEFINE_PER_CPU(struct us_ip *, gpCurIp) = NULL;
EXPORT_PER_CPU_SYMBOL_GPL(gpCurIp);
DEFINE_PER_CPU(struct pt_regs *, gpUserRegs) = NULL;
EXPORT_PER_CPU_SYMBOL_GPL(gpUserRegs);
-unsigned long ujprobe_event_pre_handler (us_proc_ip_t * ip, struct pt_regs *regs)
+unsigned long ujprobe_event_pre_handler(struct us_ip *ip, struct pt_regs *regs)
{
__get_cpu_var (gpCurIp) = ip;
__get_cpu_var (gpUserRegs) = regs;
void ujprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
- us_proc_ip_t *ip = __get_cpu_var (gpCurIp);
+ struct us_ip *ip = __get_cpu_var(gpCurIp);
unsigned long addr = (unsigned long)ip->jprobe.kp.addr;
#ifdef __ANDROID
dbi_uprobe_return ();
}
-void send_plt(us_proc_ip_t *ip)
+void send_plt(struct us_ip *ip)
{
unsigned long addr = (unsigned long)ip->jprobe.kp.addr;
struct vm_area_struct *vma = find_vma(current->mm, addr);
}
}
-int uretprobe_event_handler (struct kretprobe_instance *probe, struct pt_regs *regs, us_proc_ip_t * ip)
+int uretprobe_event_handler(struct kretprobe_instance *probe, struct pt_regs *regs, struct us_ip *ip)
{
int retval = regs_return_value(regs);
unsigned long addr = (unsigned long)ip->jprobe.kp.addr;
return 0;
}
-static int register_usprobe(struct task_struct *task, us_proc_ip_t *ip, int atomic)
+static int register_usprobe(struct task_struct *task, struct us_ip *ip, int atomic)
{
int ret = 0;
ip->jprobe.kp.tgid = task->tgid;
}
}
- ip->installed = 1;
-
return 0;
}
-static int unregister_usprobe(struct task_struct *task, us_proc_ip_t * ip, int atomic, int not_rp2)
+static int unregister_usprobe(struct task_struct *task, struct us_ip *ip, int atomic, int not_rp2)
{
dbi_unregister_ujprobe(task, &ip->jprobe, atomic);
dbi_unregister_uretprobe(task, &ip->retprobe, atomic, not_rp2);
}
- ip->installed = 0;
-
return 0;
}
}
EXPORT_SYMBOL_GPL(dump_backtrace);
-unsigned long get_ret_addr(struct task_struct *task, us_proc_ip_t *ip)
+unsigned long get_ret_addr(struct task_struct *task, struct us_ip *ip)
{
unsigned long retaddr = 0;
struct hlist_node *item, *tmp_node;
void *addr, struct pt_regs *regs, unsigned long sz);
/* Gets current function return address */
-extern unsigned long get_ret_addr(struct task_struct *task, us_proc_ip_t *ip);
+extern unsigned long get_ret_addr(struct task_struct *task, struct us_ip *ip);
#define user_backtrace(size) \
do { \