unsigned long exit_addr;
unsigned long unmap_addr;
kernel_probe_t *pf_probe = NULL;
-kernel_probe_t *cp_probe = NULL;
kernel_probe_t *mr_probe = NULL;
kernel_probe_t *exit_probe = NULL;
kernel_probe_t *unmap_probe = NULL;
{
int result;
if( ((probe == pf_probe) && (us_proc_probes & US_PROC_PF_INSTLD)) ||
- ((probe == cp_probe) && (us_proc_probes & US_PROC_CP_INSTLD)) ||
((probe == mr_probe) && (us_proc_probes & US_PROC_MR_INSTLD)) ||
((probe == unmap_probe) && (us_proc_probes & US_PROC_UNMAP_INSTLD)) ||
((probe == exit_probe) && (us_proc_probes & US_PROC_EXIT_INSTLD)))
unregister_kernel_jprobe (kernel_probe_t * probe)
{
if( ((probe == pf_probe) && (us_proc_probes & US_PROC_PF_INSTLD)) ||
- ((probe == cp_probe) && (us_proc_probes & US_PROC_CP_INSTLD)) ||
((probe == mr_probe) && (us_proc_probes & US_PROC_MR_INSTLD)) ||
((probe == unmap_probe) && (us_proc_probes & US_PROC_UNMAP_INSTLD)) ||
((probe == exit_probe) && (us_proc_probes & US_PROC_EXIT_INSTLD)) ) {
{
int result;
if( ((probe == pf_probe) && (us_proc_probes & US_PROC_PF_INSTLD)) ||
- ((probe == cp_probe) && (us_proc_probes & US_PROC_CP_INSTLD)) ||
((probe == mr_probe) && (us_proc_probes & US_PROC_MR_INSTLD)) ||
((probe == unmap_probe) && (us_proc_probes & US_PROC_UNMAP_INSTLD)) ||
((probe == exit_probe) && (us_proc_probes & US_PROC_EXIT_INSTLD)) ) {
unregister_kernel_retprobe (kernel_probe_t * probe)
{
if( ((probe == pf_probe) && (us_proc_probes & US_PROC_PF_INSTLD)) ||
- ((probe == cp_probe) && (us_proc_probes & US_PROC_CP_INSTLD)) ||
((probe == mr_probe) && (us_proc_probes & US_PROC_MR_INSTLD)) ||
((probe == unmap_probe) && (us_proc_probes & US_PROC_UNMAP_INSTLD)) ||
((probe == exit_probe) && (us_proc_probes & US_PROC_EXIT_INSTLD)) ) {
}
pprobe = &pf_probe;
}
- else if (addr == cp_addr) {
- probes_flags |= PROBE_FLAG_CP_INSTLD;
- if (us_proc_probes & US_PROC_CP_INSTLD)
- {
- return 0;
- }
- pprobe = &cp_probe;
- }
else if (addr == exit_addr) {
probes_flags |= PROBE_FLAG_EXIT_INSTLD;
if (us_proc_probes & US_PROC_EXIT_INSTLD)
if (result) {
if (addr == pf_addr)
probes_flags &= ~PROBE_FLAG_PF_INSTLD;
- else if (addr == cp_addr)
- probes_flags &= ~PROBE_FLAG_CP_INSTLD;
else if (addr == exit_addr)
probes_flags &= ~PROBE_FLAG_EXIT_INSTLD;
else if (addr == mr_addr)
if (p->addr == pf_addr) {
probes_flags &= ~PROBE_FLAG_PF_INSTLD;
pf_probe = NULL;
- } else if (p->addr == cp_addr) {
- probes_flags &= ~PROBE_FLAG_CP_INSTLD;
- cp_probe = NULL;
} else if (p->addr == exit_addr) {
probes_flags &= ~PROBE_FLAG_EXIT_INSTLD;
exit_probe = NULL;
if (p->addr == pf_addr) {
probes_flags &= ~PROBE_FLAG_PF_INSTLD;
pf_probe = NULL;
- } else if (p->addr == cp_addr) {
- probes_flags &= ~PROBE_FLAG_CP_INSTLD;
- cp_probe = NULL;
} else if (p->addr == exit_addr) {
probes_flags &= ~PROBE_FLAG_EXIT_INSTLD;
exit_probe = NULL;
}
pf_probe = NULL;
}
- else if (addr == cp_addr) {
- probes_flags &= ~PROBE_FLAG_CP_INSTLD;
- if (us_proc_probes & US_PROC_CP_INSTLD)
- {
- return 0;
- }
- cp_probe = NULL;
- }
else if (addr == mr_addr) {
probes_flags &= ~PROBE_FLAG_MR_INSTLD;
if (us_proc_probes & US_PROC_MR_INSTLD) {
skip = 1;
#endif /* CONFIG_X86 */
}
- else if (cp_probe == probe)
- {
- if (!(probes_flags & PROBE_FLAG_CP_INSTLD))
- skip = 1;
- }
else if (mr_probe == probe)
{
if (us_proc_probes & US_PROC_MR_INSTLD)
if (!(probes_flags & PROBE_FLAG_PF_INSTLD))
skip = 1;
}
- if (cp_probe == probe)
- {
- if (us_proc_probes & US_PROC_CP_INSTLD)
- copy_process_ret_pre_code((struct task_struct*)(regs_return_value(regs)));
-
- if (!(probes_flags & PROBE_FLAG_CP_INSTLD))
- skip = 1;
- }
else if (mr_probe == probe)
{
if (!(probes_flags & PROBE_FLAG_MR_INSTLD))
/* FIXME: free */
}
+static void copy_process_ret_pre_code(struct task_struct *p);
+
+static int ret_handler_cp(struct kretprobe_instance *ri, struct pt_regs *regs)
+{
+ struct task_struct* task = (struct task_struct *)regs_return_value(regs);
+
+ copy_process_ret_pre_code(task);
+
+ return 0;
+}
+
+static struct kretprobe cp_kretprobe = {
+ .handler = ret_handler_cp,
+};
+
static struct sspt_procs *get_proc_probes_by_task(struct task_struct *task)
{
struct sspt_procs *procs, *tmp;
if (iRet)
EPRINTF ("uninstall_kernel_probe(do_page_fault) result=%d!", iRet);
- iRet = uninstall_kernel_probe (cp_addr, US_PROC_CP_INSTLD,
- 0, &cp_probe);
- if (iRet)
- EPRINTF ("uninstall_kernel_probe(copy_process) result=%d!", iRet);
+ /* uninstall kretprobe with 'copy_process' */
+ dbi_unregister_kretprobe(&cp_kretprobe);
iRet = uninstall_kernel_probe (mr_addr, US_PROC_MR_INSTLD,
0, &mr_probe);
EPRINTF ("install_kernel_probe(do_exit) result=%d!", ret);
return ret;
}
- /* enable 'copy_process' */
- ret = install_kernel_probe (cp_addr, US_PROC_CP_INSTLD, 0, &cp_probe);
- if (ret != 0)
- {
- EPRINTF ("instpall_kernel_probe(copy_process) result=%d!", ret);
+ /* install kretprobe on 'copy_process' */
+ cp_kretprobe.kp.addr = cp_addr;
+ ret = dbi_register_kretprobe(&cp_kretprobe);
+ if (ret) {
+ EPRINTF("dbi_register_kretprobe(copy_process) result=%d!", ret);
return ret;
}
}
}
-void copy_process_ret_pre_code(struct task_struct *p)
+/* Delete uprobs in children at fork */
+static void copy_process_ret_pre_code(struct task_struct *p)
{
if(!p || IS_ERR(p))
return;