#include <linux/magic.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <kprobe/dbi_kprobes.h>
+#include <kprobe/swap_kprobes.h>
#include <ksyms/ksyms.h>
#include <us_manager/sspt/sspt_proc.h>
#include <us_manager/sspt/sspt_feature.h>
init_data_energy();
- ret = dbi_register_kretprobe(&sys_read_krp);
+ ret = swap_register_kretprobe(&sys_read_krp);
if (ret) {
- printk("dbi_register_kretprobe(sys_read) result=%d!\n", ret);
+ printk("swap_register_kretprobe(sys_read) result=%d!\n", ret);
return ret;
}
- ret = dbi_register_kretprobe(&sys_write_krp);
+ ret = swap_register_kretprobe(&sys_write_krp);
if (ret != 0) {
- printk("dbi_register_kretprobe(sys_write) result=%d!\n", ret);
+ printk("swap_register_kretprobe(sys_write) result=%d!\n", ret);
goto unregister_sys_read;
}
- ret = dbi_register_kretprobe(&switch_to_krp);
+ ret = swap_register_kretprobe(&switch_to_krp);
if (ret) {
- printk("dbi_register_kretprobe(__switch_to) result=%d!\n", ret);
+ printk("swap_register_kretprobe(__switch_to) result=%d!\n",
+ ret);
goto unregister_sys_write;
}
return ret;
unregister_sys_read:
- dbi_unregister_kretprobe(&sys_read_krp);
+ swap_unregister_kretprobe(&sys_read_krp);
unregister_sys_write:
- dbi_unregister_kretprobe(&sys_write_krp);
+ swap_unregister_kretprobe(&sys_write_krp);
return ret;
}
{
lcd_unset_energy();
- dbi_unregister_kretprobe(&switch_to_krp);
- dbi_unregister_kretprobe(&sys_write_krp);
- dbi_unregister_kretprobe(&sys_read_krp);
+ swap_unregister_kretprobe(&switch_to_krp);
+ swap_unregister_kretprobe(&sys_write_krp);
+ swap_unregister_kretprobe(&sys_read_krp);
uninit_data_energy();
}
*/
-#include <kprobe/dbi_kprobes.h>
+#include <kprobe/swap_kprobes.h>
#include <linux/backlight.h>
#include "lcd_base.h"
static int maru_set(struct lcd_ops *ops)
{
- return dbi_register_kretprobe(&set_backlight_krp);
+ return swap_register_kretprobe(&set_backlight_krp);
}
static int maru_unset(struct lcd_ops *ops)
{
- dbi_unregister_kretprobe(&set_backlight_krp);
+ swap_unregister_kretprobe(&set_backlight_krp);
return 0;
}
-#include <kprobe/dbi_kprobes.h>
+#include <kprobe/swap_kprobes.h>
#include "lcd_base.h"
{
int ret;
- ret = dbi_register_kretprobe(&set_power_krp);
+ ret = swap_register_kretprobe(&set_power_krp);
if (ret)
return ret;
- ret = dbi_register_kretprobe(&set_backlight_krp);
+ ret = swap_register_kretprobe(&set_backlight_krp);
if (ret)
- dbi_unregister_kretprobe(&set_power_krp);
+ swap_unregister_kretprobe(&set_power_krp);
return ret;
}
int s6e8aa0_unset(struct lcd_ops *ops)
{
- dbi_unregister_kretprobe(&set_backlight_krp);
- dbi_unregister_kretprobe(&set_power_krp);
+ swap_unregister_kretprobe(&set_backlight_krp);
+ swap_unregister_kretprobe(&set_power_krp);
return 0;
}
-#include <kprobe/dbi_kprobes.h>
+#include <kprobe/swap_kprobes.h>
#include <linux/backlight.h>
#include "lcd_base.h"
{
int ret;
- ret = dbi_register_kretprobe(&set_power_krp);
+ ret = swap_register_kretprobe(&set_power_krp);
if (ret)
return ret;
- ret = dbi_register_kretprobe(&set_backlight_krp);
+ ret = swap_register_kretprobe(&set_backlight_krp);
if (ret)
- dbi_unregister_kretprobe(&set_power_krp);
+ swap_unregister_kretprobe(&set_power_krp);
return ret;
}
int s6e8aa0_unset(struct lcd_ops *ops)
{
- dbi_unregister_kretprobe(&set_backlight_krp);
- dbi_unregister_kretprobe(&set_power_krp);
+ swap_unregister_kretprobe(&set_backlight_krp);
+ swap_unregister_kretprobe(&set_power_krp);
return 0;
}
EXTRA_CFLAGS := $(extra_cflags)
obj-m := swap_kprobe.o
-swap_kprobe-y := dbi_kprobes.o \
- dbi_kprobes_deps.o \
- arch/asm/dbi_kprobes.o \
+swap_kprobe-y := swap_kprobes.o \
+ swap_kprobes_deps.o \
+ arch/asm/swap_kprobes.o \
swap_slots.o
swap_kprobe-$(CONFIG_ARM) += arch/asm/trampoline_arm.o
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/arch/asm-arm/dbi_kprobes.c
+ * modules/kprobe/arch/asm-arm/swap_kprobes.c
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <linux/module.h>
#include <linux/mm.h>
-#include "dbi_kprobes.h"
+#include "swap_kprobes.h"
#include "trampoline_arm.h"
-#include <kprobe/dbi_kprobes.h>
+#include <kprobe/swap_kprobes.h>
-#include <kprobe/dbi_kdebug.h>
+#include <kprobe/swap_kdebug.h>
#include <kprobe/swap_slots.h>
-#include <kprobe/dbi_kprobes_deps.h>
+#include <kprobe/swap_kprobes_deps.h>
#include <ksyms/ksyms.h>
#include <asm/cacheflush.h>
entry(regs->ARM_r0, regs->ARM_r1, regs->ARM_r2,
regs->ARM_r3, regs->ARM_r4, regs->ARM_r5);
} else {
- dbi_jprobe_return();
+ swap_jprobe_return();
}
return 0;
}
-void dbi_jprobe_return (void)
+void swap_jprobe_return(void)
{
}
+EXPORT_SYMBOL_GPL(swap_jprobe_return);
int longjmp_break_handler (struct kprobe *p, struct pt_regs *regs)
{
{
int ret;
- ret = dbi_register_kprobe(&kjump_kprobe);
+ ret = swap_register_kprobe(&kjump_kprobe);
if (ret)
printk("ERROR: kjump_init(), ret=%d\n", ret);
static void kjump_exit(void)
{
- dbi_unregister_kprobe(&kjump_kprobe);
+ swap_unregister_kprobe(&kjump_kprobe);
}
-#ifndef _DBI_ASM_ARM_KPROBES_H
-#define _DBI_ASM_ARM_KPROBES_H
+#ifndef _SWAP_ASM_ARM_KPROBES_H
+#define _SWAP_ASM_ARM_KPROBES_H
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/arch/asm-arm/dbi_kprobes.h
+ * modules/kprobe/arch/asm-arm/swap_kprobes.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
task_thread_info(p)->cpu_context.pc = val;
}
-static inline struct pt_regs *dbi_get_syscall_uregs(unsigned long sp)
+static inline struct pt_regs *swap_get_syscall_uregs(unsigned long sp)
{
return (struct pt_regs *)(sp + UREGS_OFFSET);
}
-static inline unsigned long dbi_get_stack_ptr(struct pt_regs *regs)
+static inline unsigned long swap_get_stack_ptr(struct pt_regs *regs)
{
return regs->ARM_sp;
}
-static inline unsigned long dbi_get_instr_ptr(struct pt_regs *regs)
+static inline unsigned long swap_get_instr_ptr(struct pt_regs *regs)
{
return regs->ARM_pc;
}
-static inline void dbi_set_instr_ptr(struct pt_regs *regs, unsigned long val)
+static inline void swap_set_instr_ptr(struct pt_regs *regs, unsigned long val)
{
regs->ARM_pc = val;
}
-static inline unsigned long dbi_get_ret_addr(struct pt_regs *regs)
+static inline unsigned long swap_get_ret_addr(struct pt_regs *regs)
{
return regs->ARM_lr;
}
-static inline void dbi_set_ret_addr(struct pt_regs *regs, unsigned long val)
+static inline void swap_set_ret_addr(struct pt_regs *regs, unsigned long val)
{
regs->ARM_lr = val;
}
-static inline unsigned long dbi_get_arg(struct pt_regs *regs, int num)
+static inline unsigned long swap_get_arg(struct pt_regs *regs, int num)
{
return regs->uregs[num];
}
-static inline void dbi_set_arg(struct pt_regs *regs, int num, unsigned long val)
+static inline void swap_set_arg(struct pt_regs *regs, int num,
+ unsigned long val)
{
regs->uregs[num] = val;
}
//void gen_insn_execbuf_holder (void);
//void pc_dep_insn_execbuf_holder (void);
-#endif /* _DBI_ASM_ARM_KPROBES_H */
+#endif /* _SWAP_ASM_ARM_KPROBES_H */
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/arch/asm-x86/dbi_kprobes.c
+ * modules/kprobe/arch/asm-x86/swap_kprobes.c
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include<linux/module.h>
#include <linux/kdebug.h>
-#include "dbi_kprobes.h"
-#include <kprobe/dbi_kprobes.h>
+#include "swap_kprobes.h"
+#include <kprobe/swap_kprobes.h>
-#include <kprobe/dbi_kdebug.h>
+#include <kprobe/swap_kdebug.h>
#include <kprobe/swap_slots.h>
-#include <kprobe/dbi_kprobes_deps.h>
+#include <kprobe/swap_kprobes_deps.h>
#define SUPRESS_BUG_MESSAGES
extern struct kprobe * per_cpu__current_kprobe;
return 1;
}
-void dbi_jprobe_return_end(void);
+void swap_jprobe_return_end(void);
-void dbi_jprobe_return (void)
+void swap_jprobe_return(void)
{
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk ();
asm volatile(" xchgl %%ebx,%%esp \n"
" int3 \n"
- " .globl dbi_jprobe_return_end \n"
- " dbi_jprobe_return_end: \n"
+ " .globl swap_jprobe_return_end \n"
+ " swap_jprobe_return_end: \n"
" nop \n"::"b" (kcb->jprobe_saved_esp):"memory");
}
+EXPORT_SYMBOL_GPL(swap_jprobe_return);
void arch_ujprobe_return(void)
{
DBPRINTF ("p = %p\n", p);
- if ((addr > (u8 *) dbi_jprobe_return) && (addr < (u8 *) dbi_jprobe_return_end))
- {
+ if ((addr > (u8 *)swap_jprobe_return) &&
+ (addr < (u8 *)swap_jprobe_return_end)) {
if (stack_addr(regs) != kcb->jprobe_saved_esp) {
struct pt_regs *saved_regs = &kcb->jprobe_saved_regs;
printk("current esp %p does not match saved esp %p\n",
-#ifndef _SRC_ASM_X86_KPROBES_H
-#define _SRC_ASM_X86_KPROBES_H
+#ifndef _SWAP_ASM_X86_KPROBES_H
+#define _SWAP_ASM_X86_KPROBES_H
/*
* Kernel Probes (KProbes)
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/arch/asm-x86/dbi_kprobes.c
+ * modules/kprobe/arch/asm-x86/swap_kprobes.c
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*/
#include <linux/version.h>
-#include <kprobe/dbi_kprobes_deps.h>
+#include <kprobe/swap_kprobes_deps.h>
typedef u8 kprobe_opcode_t;
/* FIXME: Not implemented yet */
}
-static inline struct pt_regs *dbi_get_syscall_uregs(unsigned long sp)
+static inline struct pt_regs *swap_get_syscall_uregs(unsigned long sp)
{
return NULL; //FIXME currently not implemented for x86
}
-static inline unsigned long dbi_get_stack_ptr(struct pt_regs *regs)
+static inline unsigned long swap_get_stack_ptr(struct pt_regs *regs)
{
return regs->EREG(sp);
}
-static inline unsigned long dbi_get_instr_ptr(struct pt_regs *regs)
+static inline unsigned long swap_get_instr_ptr(struct pt_regs *regs)
{
return regs->EREG(ip);
}
-static inline void dbi_set_instr_ptr(struct pt_regs *regs, unsigned long val)
+static inline void swap_set_instr_ptr(struct pt_regs *regs, unsigned long val)
{
regs->EREG(ip) = val;
}
-static inline unsigned long dbi_get_ret_addr(struct pt_regs *regs)
+static inline unsigned long swap_get_ret_addr(struct pt_regs *regs)
{
unsigned long addr = 0;
read_proc_vm_atomic(current, regs->EREG(sp), &addr, sizeof(addr));
return addr;
}
-static inline void dbi_set_ret_addr(struct pt_regs *regs, unsigned long val)
+static inline void swap_set_ret_addr(struct pt_regs *regs, unsigned long val)
{
write_proc_vm_atomic(current, regs->EREG(sp), &val, sizeof(val));
}
-static inline unsigned long dbi_get_arg(struct pt_regs *regs, int num)
+static inline unsigned long swap_get_arg(struct pt_regs *regs, int num)
{
unsigned long arg = 0;
read_proc_vm_atomic(current, regs->EREG(sp) + (1 + num) * 4,
return arg;
}
-static inline void dbi_set_arg(struct pt_regs *regs, int num, unsigned long val)
+static inline void swap_set_arg(struct pt_regs *regs, int num,
+ unsigned long val)
{
write_proc_vm_atomic(current, regs->EREG(sp) + (1 + num) * 4,
&val, sizeof(val));
}
-static inline int dbi_fp_backtrace(struct task_struct *task, unsigned long *buf,
- int max_cnt)
+static inline int swap_fp_backtrace(struct task_struct *task,
+ unsigned long *buf, int max_cnt)
{
int i = 0;
struct pt_regs *regs;
regs = task_pt_regs(task);
frame.next = regs->EREG(bp);
- frame.raddr = dbi_get_ret_addr(regs);
+ frame.raddr = swap_get_ret_addr(regs);
while (frame.next && i < max_cnt) {
if (read_proc_vm_atomic(task, frame.next, &frame, sizeof(frame))
int arch_init_kprobes(void);
void arch_exit_kprobes(void);
-#endif /* _SRC_ASM_X86_KPROBES_H */
+#endif /* _SWAP_ASM_X86_KPROBES_H */
-#ifndef _DBI_KPROBE_DEBUG_H
-#define _DBI_KPROBE_DEBUG_H
+#ifndef _SWAP_KPROBE_DEBUG_H
+#define _SWAP_KPROBE_DEBUG_H
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/dbi_kdebug.h
+ * modules/kprobe/swap_kdebug.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#endif
-#endif /* _DBI_KPROBE_DEBUG_H */
+#endif /* _SWAP_KPROBE_DEBUG_H */
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/dbi_kprobes.h
+ * modules/kprobe/swap_kprobes.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
*/
-#include "dbi_kprobes.h"
-#include <kprobe/arch/asm/dbi_kprobes.h>
-
-#include "dbi_kdebug.h"
-#include "dbi_kprobes_deps.h"
-#include "swap_slots.h"
-#include <ksyms/ksyms.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
#include <linux/mm.h>
#include <linux/pagemap.h>
+#include <ksyms/ksyms.h>
+#include <kprobe/arch/asm/swap_kprobes.h>
+
+#include "swap_slots.h"
+#include "swap_kdebug.h"
+#include "swap_kprobes.h"
+#include "swap_kprobes_deps.h"
+
+
unsigned long sched_addr;
static unsigned long exit_addr;
static unsigned long do_group_exit_addr;
}
if (!alloc_nodes_kretprobe(rp)) {
- swap_hlist_for_each_entry(ri, node, &rp->free_instances, uflist) {
+ swap_hlist_for_each_entry(ri, node, &rp->free_instances,
+ uflist) {
return ri;
}
}
*
* The @old entry will be replaced with the @new entry atomically.
*/
-inline void dbi_hlist_replace_rcu(struct hlist_node *old, struct hlist_node *new)
+inline void swap_hlist_replace_rcu(struct hlist_node *old,
+ struct hlist_node *new)
{
struct hlist_node *next = old->next;
INIT_LIST_HEAD(&ap->list);
list_add_rcu(&p->list, &ap->list);
- dbi_hlist_replace_rcu(&p->hlist, &ap->hlist);
+ swap_hlist_replace_rcu(&p->hlist, &ap->hlist);
}
/*
swap_slot_free(&sm, p->ainsn.insn);
}
-int dbi_register_kprobe(struct kprobe *p)
+int swap_register_kprobe(struct kprobe *p)
{
struct kprobe *old_p;
int ret = 0;
DBPRINTF ("out ret = 0x%x\n", ret);
return ret;
}
+EXPORT_SYMBOL_GPL(swap_register_kprobe);
-static void dbi_unregister_valid_kprobe(struct kprobe *p, struct kprobe *old_p)
+static void swap_unregister_valid_kprobe(struct kprobe *p, struct kprobe *old_p)
{
struct kprobe *list_p;
p->addr = NULL;
}
-void dbi_unregister_kprobe(struct kprobe *kp)
+void swap_unregister_kprobe(struct kprobe *kp)
{
struct kprobe *old_p, *list_p;
list_for_each_entry_rcu(list_p, &old_p->list, list)
if (list_p == kp)
/* kprobe p is a valid probe */
- dbi_unregister_valid_kprobe(kp, old_p);
+ swap_unregister_valid_kprobe(kp, old_p);
return;
}
- dbi_unregister_valid_kprobe(kp, old_p);
+ swap_unregister_valid_kprobe(kp, old_p);
}
+EXPORT_SYMBOL_GPL(swap_unregister_kprobe);
-int dbi_register_jprobe(struct jprobe *jp)
+int swap_register_jprobe(struct jprobe *jp)
{
/* Todo: Verify probepoint is a function entry point */
jp->kp.pre_handler = setjmp_pre_handler;
jp->kp.break_handler = longjmp_break_handler;
- return dbi_register_kprobe(&jp->kp);
+ return swap_register_kprobe(&jp->kp);
}
+EXPORT_SYMBOL_GPL(swap_register_jprobe);
-void dbi_unregister_jprobe(struct jprobe *jp)
+void swap_unregister_jprobe(struct jprobe *jp)
{
- dbi_unregister_kprobe(&jp->kp);
+ swap_unregister_kprobe(&jp->kp);
}
+EXPORT_SYMBOL_GPL(swap_unregister_jprobe);
/*
* This kprobe pre_handler is registered with every kretprobe. When probe
return 0;
}
-int dbi_register_kretprobe(struct kretprobe *rp)
+int swap_register_kretprobe(struct kretprobe *rp)
{
int ret = 0;
struct kretprobe_instance *inst;
DBPRINTF ("addr=%p, *addr=[%lx %lx %lx]", rp->kp.addr, (unsigned long) (*(rp->kp.addr)), (unsigned long) (*(rp->kp.addr + 1)), (unsigned long) (*(rp->kp.addr + 2)));
rp->nmissed = 0;
/* Establish function entry probe point */
- if ((ret = dbi_register_kprobe(&rp->kp)) != 0)
+ if ((ret = swap_register_kprobe(&rp->kp)) != 0)
free_rp_inst(rp);
DBPRINTF ("addr=%p, *addr=[%lx %lx %lx]", rp->kp.addr, (unsigned long) (*(rp->kp.addr)), (unsigned long) (*(rp->kp.addr + 1)), (unsigned long) (*(rp->kp.addr + 2)));
return ret;
}
+EXPORT_SYMBOL_GPL(swap_register_kretprobe);
-static int dbi_disarm_krp_inst(struct kretprobe_instance *ri);
+static int swap_disarm_krp_inst(struct kretprobe_instance *ri);
-static void dbi_disarm_krp(struct kretprobe *rp)
+static void swap_disarm_krp(struct kretprobe *rp)
{
struct kretprobe_instance *ri;
DECLARE_NODE_PTR_FOR_HLIST(node);
swap_hlist_for_each_entry(ri, node, &rp->used_instances, uflist) {
- if (dbi_disarm_krp_inst(ri) != 0) {
+ if (swap_disarm_krp_inst(ri) != 0) {
printk("%s (%d/%d): cannot disarm krp instance (%08lx)\n",
ri->task->comm, ri->task->tgid, ri->task->pid,
(unsigned long)rp->kp.addr);
}
}
-void dbi_unregister_kretprobes_top(struct kretprobe **rps, size_t size,
+void swap_unregister_kretprobes_top(struct kretprobe **rps, size_t size,
int rp_disarm)
{
unsigned long flags;
spin_lock_irqsave(&kretprobe_lock, flags);
for (--size; size != end; --size) {
- dbi_unregister_kprobe(&rps[size]->kp);
+ swap_unregister_kprobe(&rps[size]->kp);
if (rp_disarm)
- dbi_disarm_krp(rps[size]);
+ swap_disarm_krp(rps[size]);
}
spin_unlock_irqrestore(&kretprobe_lock, flags);
}
-EXPORT_SYMBOL_GPL(dbi_unregister_kretprobes_top);
+EXPORT_SYMBOL_GPL(swap_unregister_kretprobes_top);
-void dbi_unregister_kretprobe_top(struct kretprobe *rp, int rp_disarm)
+void swap_unregister_kretprobe_top(struct kretprobe *rp, int rp_disarm)
{
- dbi_unregister_kretprobes_top(&rp, 1, rp_disarm);
+ swap_unregister_kretprobes_top(&rp, 1, rp_disarm);
}
-EXPORT_SYMBOL_GPL(dbi_unregister_kretprobe_top);
+EXPORT_SYMBOL_GPL(swap_unregister_kretprobe_top);
-void dbi_unregister_kretprobe_bottom(struct kretprobe *rp)
+void swap_unregister_kretprobe_bottom(struct kretprobe *rp)
{
unsigned long flags;
struct kretprobe_instance *ri;
spin_unlock_irqrestore(&kretprobe_lock, flags);
}
-EXPORT_SYMBOL_GPL(dbi_unregister_kretprobe_bottom);
+EXPORT_SYMBOL_GPL(swap_unregister_kretprobe_bottom);
-void dbi_unregister_kretprobes_bottom(struct kretprobe **rps, size_t size)
+void swap_unregister_kretprobes_bottom(struct kretprobe **rps, size_t size)
{
const size_t end = ((size_t) 0) - 1;
for (--size; size != end; --size)
- dbi_unregister_kretprobe_bottom(rps[size]);
+ swap_unregister_kretprobe_bottom(rps[size]);
}
-EXPORT_SYMBOL_GPL(dbi_unregister_kretprobes_bottom);
+EXPORT_SYMBOL_GPL(swap_unregister_kretprobes_bottom);
-void dbi_unregister_kretprobes(struct kretprobe **rpp, size_t size)
+void swap_unregister_kretprobes(struct kretprobe **rpp, size_t size)
{
- dbi_unregister_kretprobes_top(rpp, size, 1);
+ swap_unregister_kretprobes_top(rpp, size, 1);
if (!in_atomic())
synchronize_sched();
- dbi_unregister_kretprobes_bottom(rpp, size);
+ swap_unregister_kretprobes_bottom(rpp, size);
}
+EXPORT_SYMBOL_GPL(swap_unregister_kretprobes);
-void dbi_unregister_kretprobe(struct kretprobe *rp)
+void swap_unregister_kretprobe(struct kretprobe *rp)
{
- dbi_unregister_kretprobes(&rp, 1);
+ swap_unregister_kretprobes(&rp, 1);
}
+EXPORT_SYMBOL_GPL(swap_unregister_kretprobe);
static void inline rm_task_trampoline(struct task_struct *p, struct kretprobe_instance *ri)
{
arch_set_task_pc(p, (unsigned long)ri->ret_addr);
}
-static int dbi_disarm_krp_inst(struct kretprobe_instance *ri)
+static int swap_disarm_krp_inst(struct kretprobe_instance *ri)
{
unsigned long *tramp = (unsigned long *)&kretprobe_trampoline;
unsigned long *sp = ri->sp;
module_init(init_kprobes);
module_exit(exit_kprobes);
-EXPORT_SYMBOL_GPL(dbi_register_kprobe);
-EXPORT_SYMBOL_GPL(dbi_unregister_kprobe);
-EXPORT_SYMBOL_GPL(dbi_register_jprobe);
-EXPORT_SYMBOL_GPL(dbi_unregister_jprobe);
-EXPORT_SYMBOL_GPL(dbi_jprobe_return);
-EXPORT_SYMBOL_GPL(dbi_register_kretprobe);
-EXPORT_SYMBOL_GPL(dbi_unregister_kretprobes);
-EXPORT_SYMBOL_GPL(dbi_unregister_kretprobe);
-
MODULE_LICENSE("Dual BSD/GPL");
-#ifndef _DBI_KPROBES_H
-#define _DBI_KPROBES_H
+#ifndef _SWAP_KPROBES_H
+#define _SWAP_KPROBES_H
/*
* Kernel Probes (KProbes)
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/dbi_kprobes.h
+ * modules/kprobe/swap_kprobes.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <linux/sched.h>
#include <linux/pagemap.h>
-#include <kprobe/arch/asm/dbi_kprobes.h>
+#include <kprobe/arch/asm/swap_kprobes.h>
#ifdef CONFIG_ARM
struct kprobe *get_kprobe(void *addr);
-int dbi_register_kprobe (struct kprobe *p);
-void dbi_unregister_kprobe(struct kprobe *p);
+int swap_register_kprobe(struct kprobe *p);
+void swap_unregister_kprobe(struct kprobe *p);
int setjmp_pre_handler (struct kprobe *, struct pt_regs *);
int longjmp_break_handler (struct kprobe *, struct pt_regs *);
-int dbi_register_jprobe (struct jprobe *p);
-void dbi_unregister_jprobe (struct jprobe *p);
-void dbi_jprobe_return (void);
+int swap_register_jprobe(struct jprobe *p);
+void swap_unregister_jprobe(struct jprobe *p);
+void swap_jprobe_return(void);
-int dbi_register_kretprobe (struct kretprobe *rp);
-void dbi_unregister_kretprobe (struct kretprobe *rp);
-void dbi_unregister_kretprobes(struct kretprobe **rpp, size_t size);
+int swap_register_kretprobe(struct kretprobe *rp);
+void swap_unregister_kretprobe(struct kretprobe *rp);
+void swap_unregister_kretprobes(struct kretprobe **rpp, size_t size);
/*
* use:
- * dbi_unregister_kretprobe[s]_top();
+ * swap_unregister_kretprobe[s]_top();
* synchronize_sched();
- * dbi_unregister_kretprobe[s]_bottom();
+ * swap_unregister_kretprobe[s]_bottom();
*
* rp_disarm - indicates the need for restoration of the return address
*/
-void dbi_unregister_kretprobe_top(struct kretprobe *rp, int rp_disarm);
-void dbi_unregister_kretprobes_top(struct kretprobe **rps, size_t size,
+void swap_unregister_kretprobe_top(struct kretprobe *rp, int rp_disarm);
+void swap_unregister_kretprobes_top(struct kretprobe **rps, size_t size,
int rp_disarm);
-void dbi_unregister_kretprobe_bottom(struct kretprobe *rp);
-void dbi_unregister_kretprobes_bottom(struct kretprobe **rps, size_t size);
+void swap_unregister_kretprobe_bottom(struct kretprobe *rp);
+void swap_unregister_kretprobes_bottom(struct kretprobe **rps, size_t size);
-int dbi_disarm_urp_inst_for_task(struct task_struct *parent, struct task_struct *task);
+int swap_disarm_urp_inst_for_task(struct task_struct *parent, struct task_struct *task);
int trampoline_probe_handler (struct kprobe *p, struct pt_regs *regs);
void prepare_singlestep(struct kprobe *p, struct pt_regs *regs);
-#endif /* _DBI_KPROBES_H */
+#endif /* _SWAP_KPROBES_H */
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/dbi_kprobes_deps.h
+ * modules/kprobe/swap_kprobes_deps.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <asm/pgtable.h>
-#include "dbi_kprobes_deps.h"
-#include "dbi_kdebug.h"
+#include "swap_kprobes_deps.h"
+#include "swap_kdebug.h"
#include <linux/slab.h>
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38)) */
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36)
-static inline void *dbi_kmap_atomic(struct page *page)
+static inline void *swap_kmap_atomic(struct page *page)
{
return kmap_atomic(page);
}
-static inline void dbi_kunmap_atomic(void *kvaddr)
+static inline void swap_kunmap_atomic(void *kvaddr)
{
kunmap_atomic(kvaddr);
}
#else /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 36) */
-static inline void *dbi_kmap_atomic(struct page *page)
+static inline void *swap_kmap_atomic(struct page *page)
{
return kmap_atomic(page, KM_USER0);
}
-static inline void dbi_kunmap_atomic(void *kvaddr)
+static inline void swap_kunmap_atomic(void *kvaddr)
{
kunmap_atomic(kvaddr, KM_USER0);
}
#define swap_follow_hugetlb_page follow_hugetlb_page
#endif /* CONFIG_HUGETLB_PAGE */
-static inline int dbi_in_gate_area(struct task_struct *task, unsigned long addr)
+static inline int swap_in_gate_area(struct task_struct *task, unsigned long addr)
{
#ifdef __HAVE_ARCH_GATE_AREA
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38)
IMP_MOD_DEP_WRAPPER(in_gate_area_no_task, addr)
#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
-static inline int dbi_in_gate_area_no_xxx(unsigned long addr)
+static inline int swap_in_gate_area_no_xxx(unsigned long addr)
{
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38)
return swap_in_gate_area_no_mm(addr);
struct vm_area_struct *vma;
vma = swap_find_extend_vma(mm, start);
- if (!vma && dbi_in_gate_area(tsk, start)) {
+ if (!vma && swap_in_gate_area(tsk, start)) {
unsigned long pg = start & PAGE_MASK;
pgd_t *pgd;
pud_t *pud;
struct vm_area_struct *vma;
vma = swap_find_extend_vma(mm, start);
- if (!vma && dbi_in_gate_area_no_xxx(start)) {
+ if (!vma && swap_in_gate_area_no_xxx(start)) {
unsigned long pg = start & PAGE_MASK;
pgd_t *pgd;
pud_t *pud;
unsigned int foll_flags;
vma = find_vma(mm, start);
- if (!vma && dbi_in_gate_area(tsk, start)) {
+ if (!vma && swap_in_gate_area(tsk, start)) {
unsigned long pg = start & PAGE_MASK;
struct vm_area_struct *gate_vma = swap_get_gate_vma(tsk);
pgd_t *pgd;
if (bytes > PAGE_SIZE-offset)
bytes = PAGE_SIZE-offset;
- maddr = atomic ? dbi_kmap_atomic(page) : kmap(page);
+ maddr = atomic ? swap_kmap_atomic(page) : kmap(page);
if (write) {
swap_copy_to_user_page(vma, page, addr,
buf, maddr + offset, bytes);
}
- atomic ? dbi_kunmap_atomic(maddr) : kunmap(page);
+ atomic ? swap_kunmap_atomic(maddr) : kunmap(page);
page_cache_release(page);
}
len -= bytes;
-#ifndef _DBI_KPROBES_DEPS_H
-#define _DBI_KPROBES_DEPS_H
+#ifndef _SWAP_KPROBES_DEPS_H
+#define _SWAP_KPROBES_DEPS_H
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/dbi_kprobes_deps.h
+ * modules/kprobe/swap_kprobes_deps.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
int page_present (struct mm_struct *mm, unsigned long addr);
-#endif /* _DBI_KPROBES_DEPS_H */
+#endif /* _SWAP_KPROBES_DEPS_H */
#include <linux/spinlock.h>
#include "swap_slots.h"
-#include "dbi_kprobes_deps.h"
+#include "swap_kprobes_deps.h"
struct chunk {
#include <asm/errno.h>
#include <ksyms/ksyms.h>
-#include <kprobe/dbi_kprobes.h>
+#include <kprobe/swap_kprobes.h>
#include <writer/swap_writer_module.h>
#include "ks_features.h"
#include "syscall_list.h"
void exit_switch_context(void)
{
if (sc_enable)
- dbi_unregister_kretprobe(&switch_rp);
+ swap_unregister_kretprobe(&switch_rp);
}
static int register_switch_context(void)
goto unlock;
}
- ret = dbi_register_kretprobe(&switch_rp);
+ ret = swap_register_kretprobe(&switch_rp);
if (ret == 0)
sc_enable = 1;
goto unlock;
}
- dbi_unregister_kretprobe(&switch_rp);
+ swap_unregister_kretprobe(&switch_rp);
sc_enable = 0;
unlock:
ksp[id].rp.entry_handler = entry_handler;
ksp[id].rp.handler = ret_handler;
- ret = dbi_register_kretprobe(&ksp[id].rp);
+ ret = swap_register_kretprobe(&ksp[id].rp);
return ret;
}
if (ksp[id].rp.kp.addr == NULL)
return 0;
- dbi_unregister_kretprobe(&ksp[id].rp);
+ swap_unregister_kretprobe(&ksp[id].rp);
return 0;
}
}
}
- dbi_unregister_kretprobes(rpp, i);
+ swap_unregister_kretprobes(rpp, i);
kfree(rpp);
return 0;
#include <linux/module.h>
#include <linux/slab.h>
-#include <kprobe/dbi_kprobes.h>
-#include <kprobe/dbi_kprobes_deps.h>
+#include <kprobe/swap_kprobes.h>
+#include <kprobe/swap_kprobes_deps.h>
#include "ks_manager.h"
struct probe {
if (!p)
return -ENOMEM;
- ret = dbi_register_jprobe(&p->p.jp);
+ ret = swap_register_jprobe(&p->p.jp);
if (ret)
goto free;
- ret = dbi_register_kretprobe(&p->p.rp);
+ ret = swap_register_kretprobe(&p->p.rp);
if (ret)
goto unregister_jprobe;
return 0;
unregister_jprobe:
- dbi_unregister_jprobe(&p->p.jp);
+ swap_unregister_jprobe(&p->p.jp);
free:
free_probe(p);
return ret;
static void do_ksm_unregister_probe(struct probe *p)
{
remove_probe_to_list(p);
- dbi_unregister_kretprobe(&p->p.rp);
- dbi_unregister_jprobe(&p->p.jp);
+ swap_unregister_kretprobe(&p->p.rp);
+ swap_unregister_jprobe(&p->p.jp);
free_probe(p);
}
*
*/
-#include <kprobe/dbi_kprobes.h>
+#include <kprobe/swap_kprobes.h>
struct kern_probe {
struct jprobe jp;
static u64 sampler_timer_quantum = 0;
-static DEFINE_PER_CPU(struct hrtimer, dbi_hrtimer);
-static int dbi_hrtimer_running;
+static DEFINE_PER_CPU(struct hrtimer, swap_hrtimer);
+static int swap_hrtimer_running;
restart_ret sampler_timers_restart(swap_timer *timer)
{
void sampler_timers_set_run(void)
{
- dbi_hrtimer_running = 1;
+ swap_hrtimer_running = 1;
}
void sampler_timers_set_stop(void)
{
- dbi_hrtimer_running = 0;
+ swap_hrtimer_running = 0;
}
void sampler_timers_start(void *restart_func)
{
- struct hrtimer *hrtimer = &__get_cpu_var(dbi_hrtimer);
+ struct hrtimer *hrtimer = &__get_cpu_var(swap_hrtimer);
- if (!dbi_hrtimer_running)
+ if (!swap_hrtimer_running)
return;
hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
void sampler_timers_stop(int cpu)
{
- struct hrtimer *hrtimer = &per_cpu(dbi_hrtimer, cpu);
+ struct hrtimer *hrtimer = &per_cpu(swap_hrtimer, cpu);
- if (!dbi_hrtimer_running)
+ if (!swap_hrtimer_running)
return;
hrtimer_cancel(hrtimer);
static unsigned long sampler_timer_quantum = 0;
-static DEFINE_PER_CPU(struct timer_list, dbi_timer);
-static int dbi_timer_running;
+static DEFINE_PER_CPU(struct timer_list, swap_timer);
+static int swap_timer_running;
restart_ret sampler_timers_restart(swap_timer *timer)
void sampler_timers_set_run(void)
{
- dbi_timer_running = 1;
+ swap_timer_running = 1;
}
void sampler_timers_set_stop(void)
{
- dbi_timer_running = 0;
+ swap_timer_running = 0;
}
void sampler_timers_start(void *restart_func)
{
- struct timer_list *timer = &__get_cpu_var(dbi_timer);
+ struct timer_list *timer = &__get_cpu_var(swap_timer);
- if (!dbi_timer_running)
+ if (!swap_timer_running)
return;
init_timer(timer);
void sampler_timers_stop(int cpu)
{
- struct timer_list *timer = &per_cpu(dbi_timer, cpu);
+ struct timer_list *timer = &per_cpu(swap_timer, cpu);
- if (!dbi_timer_running)
+ if (!swap_timer_running)
return;
del_timer_sync(timer);
}
static BLOCKING_NOTIFIER_HEAD(swap_sampler_notifier_list);
-static restart_ret dbi_timer_restart(swap_timer *timer)
+static restart_ret swap_timer_restart(swap_timer *timer)
{
if (current)
sample_msg(task_pt_regs(current));
return sampler_timers_restart(timer);
}
-static int dbi_timer_start(void)
+static int swap_timer_start(void)
{
get_online_cpus();
sampler_timers_set_run();
- on_each_cpu(sampler_timers_start, dbi_timer_restart, 1);
+ on_each_cpu(sampler_timers_start, swap_timer_restart, 1);
put_online_cpus();
return E_SS_SUCCESS;
}
-static void dbi_timer_stop(void)
+static void swap_timer_stop(void)
{
int cpu;
put_online_cpus();
}
-static int __cpuinit dbi_cpu_notify(struct notifier_block *self,
+static int __cpuinit swap_cpu_notify(struct notifier_block *self,
unsigned long action, void *hcpu)
{
long cpu = (long) hcpu;
case CPU_ONLINE:
case CPU_ONLINE_FROZEN:
smp_call_function_single(cpu, sampler_timers_start,
- dbi_timer_restart, 1);
+ swap_timer_restart, 1);
break;
case CPU_DEAD:
case CPU_DEAD_FROZEN:
return NOTIFY_OK;
}
-static struct notifier_block __refdata dbi_cpu_notifier = {
- .notifier_call = dbi_cpu_notify,
+static struct notifier_block __refdata swap_cpu_notifier = {
+ .notifier_call = swap_cpu_notify,
};
static int do_swap_sampler_start(unsigned int timer_quantum)
return -EINVAL;
sampler_timers_set_quantum(timer_quantum);
- dbi_timer_start();
+ swap_timer_start();
return 0;
}
static void do_swap_sampler_stop(void)
{
- dbi_timer_stop();
+ swap_timer_stop();
}
static DEFINE_MUTEX(mutex_run);
{
int retval;
- retval = register_hotcpu_notifier(&dbi_cpu_notifier);
+ retval = register_hotcpu_notifier(&swap_cpu_notifier);
if (retval) {
print_err("Error of register_hotcpu_notifier()\n");
return retval;
if (sampler_run)
do_swap_sampler_stop();
- unregister_hotcpu_notifier(&dbi_cpu_notifier);
+ unregister_hotcpu_notifier(&swap_cpu_notifier);
print_msg("Sampler uninitialized\n");
}
*
*/
-#include <kprobe/dbi_kprobes.h>
-#include <kprobe/arch/asm/dbi_kprobes.h>
+#include <kprobe/swap_kprobes.h>
+#include <kprobe/arch/asm/swap_kprobes.h>
#include <kprobe/arch/asm/trampoline_arm.h>
#include <asm/traps.h>
#include <uprobe/swap_uprobes.h>
#include <uprobe/arch/asm/swap_uprobes.h>
#include <kprobe/swap_slots.h>
-#include <kprobe/dbi_kprobes_deps.h>
+#include <kprobe/swap_kprobes_deps.h>
#include "trampoline_thumb.h"
// FIXME:
-#include <kprobe/dbi_kdebug.h>
+#include <kprobe/swap_kdebug.h>
#define flush_insns(addr, size) \
struct task_struct *task)
{
struct pt_regs *uregs = task_pt_regs(ri->task);
- unsigned long ra = dbi_get_ret_addr(uregs);
+ unsigned long ra = swap_get_ret_addr(uregs);
unsigned long *tramp;
unsigned long *sp = (unsigned long *)((long)ri->sp & ~1);
unsigned long *stack = sp - RETPROBE_STACK_DEPTH + 1;
"lr = %08lx - %p\n",
task->comm, task->tgid, task->pid,
ra, ri->rp->up.kp.addr);
- dbi_set_ret_addr(uregs, (unsigned long)ri->ret_addr);
+ swap_set_ret_addr(uregs, (unsigned long)ri->ret_addr);
retval = 0;
} else if (retval) {
printk("---> %s (%d/%d): trampoline NOT found at "
#define _ARM_SWAP_UPROBES_H
-#include <kprobe/arch/asm/dbi_kprobes.h>
-
-
struct kprobe;
struct task_struct;
struct uprobe;
*/
#include <linux/kdebug.h>
-#include <kprobe/arch/asm/dbi_kprobes.h>
#include <uprobe/swap_uprobes.h>
#include <uprobe/arch/asm/swap_uprobes.h>
#include <kprobe/swap_slots.h>
*
*/
-#ifndef _ARM_SWAP_UPROBES_H
-#define _ARM_SWAP_UPROBES_H
-
-
-#include <kprobe/arch/asm/dbi_kprobes.h>
+#ifndef _X86_SWAP_UPROBES_H
+#define _X86_SWAP_UPROBES_H
struct uprobe;
int swap_arch_init_uprobes(void);
void swap_arch_exit_uprobes(void);
-#endif /* _ARM_SWAP_UPROBES_H */
+#endif /* _X86_SWAP_UPROBES_H */
#include "swap_uprobes.h"
-#include <kprobe/dbi_kdebug.h>
+#include <kprobe/swap_kdebug.h>
#include <uprobe/arch/asm/swap_uprobes.h>
#include <linux/mempolicy.h>
#include <linux/module.h>
#include <kprobe/swap_slots.h>
-#include <kprobe/dbi_kprobes_deps.h>
+#include <kprobe/swap_kprobes_deps.h>
enum {
UPROBE_HASH_BITS = 10,
}
// ===================================================================
-int dbi_register_uprobe(struct uprobe *up)
+int swap_register_uprobe(struct uprobe *up)
{
int ret = 0;
struct kprobe *p, *old_p;
return ret;
}
-void __dbi_unregister_uprobe(struct uprobe *up, int disarm)
+void __swap_unregister_uprobe(struct uprobe *up, int disarm)
{
struct kprobe *p, *old_p, *list_p;
int cleanup_p;
}
}
}
-EXPORT_SYMBOL_GPL(__dbi_unregister_uprobe);
+EXPORT_SYMBOL_GPL(__swap_unregister_uprobe);
-void dbi_unregister_uprobe(struct uprobe *up)
+void swap_unregister_uprobe(struct uprobe *up)
{
- __dbi_unregister_uprobe(up, 1);
+ __swap_unregister_uprobe(up, 1);
}
-int dbi_register_ujprobe(struct ujprobe *jp)
+int swap_register_ujprobe(struct ujprobe *jp)
{
int ret = 0;
jp->up.kp.pre_handler = setjmp_upre_handler;
jp->up.kp.break_handler = longjmp_break_uhandler;
- ret = dbi_register_uprobe(&jp->up);
+ ret = swap_register_uprobe(&jp->up);
return ret;
}
+EXPORT_SYMBOL_GPL(swap_register_ujprobe);
-void __dbi_unregister_ujprobe(struct ujprobe *jp, int disarm)
+void __swap_unregister_ujprobe(struct ujprobe *jp, int disarm)
{
- __dbi_unregister_uprobe(&jp->up, disarm);
+ __swap_unregister_uprobe(&jp->up, disarm);
/*
* Here is an attempt to unregister even those probes that have not been
* installed (hence not added to the hlist).
hlist_del_rcu(&jp->up.kp.is_hlist);
}
}
-EXPORT_SYMBOL_GPL(__dbi_unregister_ujprobe);
+EXPORT_SYMBOL_GPL(__swap_unregister_ujprobe);
-void dbi_unregister_ujprobe(struct ujprobe *jp)
+void swap_unregister_ujprobe(struct ujprobe *jp)
{
- __dbi_unregister_ujprobe(jp, 1);
+ __swap_unregister_ujprobe(jp, 1);
}
+EXPORT_SYMBOL_GPL(swap_unregister_ujprobe);
int trampoline_uprobe_handler(struct kprobe *p, struct pt_regs *regs)
{
return 0;
}
-int dbi_register_uretprobe(struct uretprobe *rp)
+int swap_register_uretprobe(struct uretprobe *rp)
{
int i, ret = 0;
struct uretprobe_instance *inst;
rp->nmissed = 0;
/* Establish function entry probe point */
- ret = dbi_register_uprobe(&rp->up);
+ ret = swap_register_uprobe(&rp->up);
if (ret)
return ret;
return 0;
}
+EXPORT_SYMBOL_GPL(swap_register_uretprobe);
-int dbi_disarm_urp_inst_for_task(struct task_struct *parent, struct task_struct *task)
+int swap_disarm_urp_inst_for_task(struct task_struct *parent, struct task_struct *task)
{
unsigned long flags;
struct uretprobe_instance *ri;
return 0;
}
-EXPORT_SYMBOL_GPL(dbi_disarm_urp_inst_for_task);
+EXPORT_SYMBOL_GPL(swap_disarm_urp_inst_for_task);
-void dbi_discard_pending_uretprobes(struct task_struct *task)
+void swap_discard_pending_uretprobes(struct task_struct *task)
{
unsigned long flags;
struct uretprobe_instance *ri;
spin_unlock_irqrestore(&uretprobe_lock, flags);
}
-EXPORT_SYMBOL_GPL(dbi_discard_pending_uretprobes);
+EXPORT_SYMBOL_GPL(swap_discard_pending_uretprobes);
-void __dbi_unregister_uretprobe(struct uretprobe *rp, int disarm)
+void __swap_unregister_uretprobe(struct uretprobe *rp, int disarm)
{
unsigned long flags;
struct uretprobe_instance *ri;
- __dbi_unregister_uprobe(&rp->up, disarm);
+ __swap_unregister_uprobe(&rp->up, disarm);
spin_lock_irqsave (&uretprobe_lock, flags);
while ((ri = get_used_urp_inst(rp)) != NULL) {
spin_unlock_irqrestore(&uretprobe_lock, flags);
free_urp_inst(rp);
}
-EXPORT_SYMBOL_GPL(__dbi_unregister_uretprobe);
+EXPORT_SYMBOL_GPL(__swap_unregister_uretprobe);
-void dbi_unregister_uretprobe(struct uretprobe *rp)
+void swap_unregister_uretprobe(struct uretprobe *rp)
{
- __dbi_unregister_uretprobe(rp, 1);
+ __swap_unregister_uretprobe(rp, 1);
}
+EXPORT_SYMBOL_GPL(swap_unregister_uretprobe);
-void dbi_unregister_all_uprobes(struct task_struct *task)
+void swap_unregister_all_uprobes(struct task_struct *task)
{
struct hlist_head *head;
struct kprobe *p;
swap_hlist_for_each_entry_safe(p, node, tnode, head, hlist) {
if (kp2up(p)->task->tgid == task->tgid) {
struct uprobe *up = container_of(p, struct uprobe, kp);
- printk("dbi_unregister_all_uprobes: delete uprobe at %p[%lx] for %s/%d\n",
- p->addr, (unsigned long)p->opcode, task->comm, task->pid);
- dbi_unregister_uprobe(up);
+ printk("%s: delete uprobe at %p[%lx] for "
+ "%s/%d\n", __func__, p->addr,
+ (unsigned long)p->opcode,
+ task->comm, task->pid);
+ swap_unregister_uprobe(up);
}
}
}
}
+EXPORT_SYMBOL_GPL(swap_unregister_all_uprobes);
void swap_ujprobe_return(void)
{
swap_arch_exit_uprobes();
}
-EXPORT_SYMBOL_GPL(dbi_register_ujprobe);
-EXPORT_SYMBOL_GPL(dbi_unregister_ujprobe);
-EXPORT_SYMBOL_GPL(dbi_register_uretprobe);
-EXPORT_SYMBOL_GPL(dbi_unregister_uretprobe);
-EXPORT_SYMBOL_GPL(dbi_unregister_all_uprobes);
-
module_init(init_uprobes);
module_exit(exit_uprobes);
-#ifndef _DBI_UPROBES_H
-#define _DBI_UPROBES_H
+#ifndef _SWAP_UPROBES_H
+#define _SWAP_UPROBES_H
/*
* Dynamic Binary Instrumentation Module based on KProbes
*
*/
-#include <kprobe/dbi_kprobes.h>
+#include <kprobe/swap_kprobes.h>
#include <uprobe/arch/asm/swap_uprobes.h>
struct task_struct *task;
};
-int dbi_register_uprobe(struct uprobe *p);
-void dbi_unregister_uprobe(struct uprobe *p);
-void __dbi_unregister_uprobe(struct uprobe *up, int disarm);
+int swap_register_uprobe(struct uprobe *p);
+void swap_unregister_uprobe(struct uprobe *p);
+void __swap_unregister_uprobe(struct uprobe *up, int disarm);
-int dbi_register_ujprobe(struct ujprobe *jp);
-void dbi_unregister_ujprobe(struct ujprobe *jp);
-void __dbi_unregister_ujprobe(struct ujprobe *jp, int disarm);
+int swap_register_ujprobe(struct ujprobe *jp);
+void swap_unregister_ujprobe(struct ujprobe *jp);
+void __swap_unregister_ujprobe(struct ujprobe *jp, int disarm);
-int dbi_register_uretprobe(struct uretprobe *rp);
-void dbi_unregister_uretprobe(struct uretprobe *rp);
-void __dbi_unregister_uretprobe(struct uretprobe *rp, int disarm);
+int swap_register_uretprobe(struct uretprobe *rp);
+void swap_unregister_uretprobe(struct uretprobe *rp);
+void __swap_unregister_uretprobe(struct uretprobe *rp, int disarm);
-void dbi_unregister_all_uprobes(struct task_struct *task);
-void dbi_discard_pending_uretprobes(struct task_struct *task);
+void swap_unregister_all_uprobes(struct task_struct *task);
+void swap_discard_pending_uretprobes(struct task_struct *task);
void swap_ujprobe_return(void);
struct kprobe *get_ukprobe(void *addr, pid_t tgid);
void add_uprobe_table(struct kprobe *p);
-#endif /* _DBI_UPROBES_H */
+#endif /* _SWAP_UPROBES_H */
*/
-#include <kprobe/dbi_kprobes.h>
-#include <kprobe/dbi_kprobes_deps.h>
+#include <kprobe/swap_kprobes.h>
+#include <kprobe/swap_kprobes_deps.h>
#include <ksyms/ksyms.h>
#include <writer/kernel_operations.h>
#include <writer/swap_writer_module.h>
{
int ret;
- ret = dbi_register_kretprobe(&mf_kretprobe);
+ ret = swap_register_kretprobe(&mf_kretprobe);
if (ret)
- printk("dbi_register_kretprobe(handle_mm_fault) ret=%d!\n",
+ printk("swap_register_kretprobe(handle_mm_fault) ret=%d!\n",
ret);
return ret;
static void unregister_mf(void)
{
- dbi_unregister_kretprobe(&mf_kretprobe);
+ swap_unregister_kretprobe(&mf_kretprobe);
}
{
int ret = 0;
- ret = dbi_register_kprobe(&ctx_task_kprobe);
+ ret = swap_register_kprobe(&ctx_task_kprobe);
if (ret)
- printk("dbi_register_kprobe(workaround) ret=%d!\n", ret);
+ printk("swap_register_kprobe(workaround) ret=%d!\n", ret);
return ret;
}
static void unregister_ctx_task(void)
{
- dbi_unregister_kprobe(&ctx_task_kprobe);
+ swap_unregister_kprobe(&ctx_task_kprobe);
}
#endif /* CONFIG_ARM */
static void recover_child(struct task_struct *child_task, struct sspt_proc *proc)
{
sspt_proc_uninstall(proc, child_task, US_DISARM);
- dbi_disarm_urp_inst_for_task(current, child_task);
+ swap_disarm_urp_inst_for_task(current, child_task);
}
static void rm_uprobes_child(struct task_struct *task)
{
int ret;
- ret = dbi_register_kretprobe(&cp_kretprobe);
+ ret = swap_register_kretprobe(&cp_kretprobe);
if (ret)
- printk("dbi_register_kretprobe(copy_process) ret=%d!\n", ret);
+ printk("swap_register_kretprobe(copy_process) ret=%d!\n", ret);
return ret;
}
static void unregister_cp(void)
{
- dbi_unregister_kretprobe_top(&cp_kretprobe, 0);
+ swap_unregister_kretprobe_top(&cp_kretprobe, 0);
do {
synchronize_sched();
} while (atomic_read(©_process_cnt));
- dbi_unregister_kretprobe_bottom(&cp_kretprobe);
+ swap_unregister_kretprobe_bottom(&cp_kretprobe);
}
if (task->tgid != task->pid) {
/* if the thread is killed we need to discard pending
* uretprobe instances which have not triggered yet */
- dbi_discard_pending_uretprobes(task);
+ swap_discard_pending_uretprobes(task);
goto out;
}
{
int ret;
- ret = dbi_register_kprobe(&mr_kprobe);
+ ret = swap_register_kprobe(&mr_kprobe);
if (ret)
- printk("dbi_register_kprobe(mm_release) ret=%d!\n", ret);
+ printk("swap_register_kprobe(mm_release) ret=%d!\n", ret);
return ret;
}
static void unregister_mr(void)
{
- dbi_unregister_kprobe(&mr_kprobe);
+ swap_unregister_kprobe(&mr_kprobe);
}
{
int ret;
- ret = dbi_register_kretprobe(&unmap_kretprobe);
+ ret = swap_register_kretprobe(&unmap_kretprobe);
if (ret)
- printk("dbi_register_kprobe(do_munmap) ret=%d!\n", ret);
+ printk("swap_register_kprobe(do_munmap) ret=%d!\n", ret);
return ret;
}
static void unregister_unmap(void)
{
- dbi_unregister_kretprobe_top(&unmap_kretprobe, 0);
+ swap_unregister_kretprobe_top(&unmap_kretprobe, 0);
do {
synchronize_sched();
} while (atomic_read(&unmap_cnt));
- dbi_unregister_kretprobe_bottom(&unmap_kretprobe);
+ swap_unregister_kretprobe_bottom(&unmap_kretprobe);
}
{
int ret;
- ret = dbi_register_kretprobe(&mmap_kretprobe);
+ ret = swap_register_kretprobe(&mmap_kretprobe);
if (ret)
- printk("dbi_register_kretprobe(do_mmap_pgoff) ret=%d!\n", ret);
+ printk("swap_register_kretprobe(do_mmap_pgoff) ret=%d!\n", ret);
return ret;
}
static void unregister_mmap(void)
{
- dbi_unregister_kretprobe(&mmap_kretprobe);
+ swap_unregister_kretprobe(&mmap_kretprobe);
}
ip->retprobe.up.task = ip->page->file->proc->task;
ip->retprobe.up.sm = ip->page->file->proc->sm;
- ret = dbi_register_uretprobe(&ip->retprobe);
+ ret = swap_register_uretprobe(&ip->retprobe);
if (ret) {
struct sspt_file *file = ip->page->file;
char *name = file->dentry->d_iname;
unsigned long addr = (unsigned long)ip->retprobe.up.kp.addr;
unsigned long offset = addr - file->vm_start;
- printk("dbi_register_uretprobe() failure %d (%s:%lx|%lx)\n",
+ printk("swap_register_uretprobe() failure %d (%s:%lx|%lx)\n",
ret, name, offset, (unsigned long)ip->retprobe.up.kp.opcode);
}
static inline int do_unregister_usprobe(struct us_ip *ip, int disarm)
{
- __dbi_unregister_uretprobe(&ip->retprobe, disarm);
+ __swap_unregister_uretprobe(&ip->retprobe, disarm);
return 0;
}
*
*/
-#include <kprobe/dbi_kprobes_deps.h>
+#include <kprobe/swap_kprobes_deps.h>
static inline void print_jprobe(struct jprobe *jp)
{
#include <linux/list.h>
#include <linux/hash.h>
#include <linux/sched.h>
-#include <kprobe/dbi_kprobes_deps.h>
+#include <kprobe/swap_kprobes_deps.h>
static int calculation_hash_bits(int cnt)
{
#include <linux/mman.h>
#include <linux/list.h>
#include <kprobe/swap_slots.h>
-#include <kprobe/arch/asm/dbi_kprobes.h>
+#include <kprobe/arch/asm/swap_kprobes.h>
#include "us_manager_common.h"
#include <linux/module.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
-#include <kprobe/arch/asm/dbi_kprobes.h>
+#include <kprobe/arch/asm/swap_kprobes.h>
#include <uprobe/arch/asm/swap_uprobes.h>
#include <buffer/swap_buffer_module.h>