该函数的参数是struct kprobe类型的指针。 该注册函数会在kp->addr地址处注册一个kprobes类型的探测点,当执行到该探测点时,将调用函数kp->pre_handler()执行完被探测函数后,将调用kp->post_handler()。如果在执行kp->pre_handler()、kp->post_handler()或在单步跟踪被探测函数期间发生错误,将调用kp->fault_...
kprobe_post_handler_t post_handler:在被探测指令执行之后调用的回调函数; kprobe_fault_handler_t fault_handler:在执行pre_handler、post_handler或单步执行被探测指令时出现内存异常则会调用该回调函数; kprobe_break_handler_t break_handler:在执行某一kprobe过程中触发了断点指令后会调用该函数,用于实现jprobe; ...
handler_pre回调函数的第一个入参是注册的struct kprobe探测实例,第二个参数是保存的触发断点前的寄存器状态,它在do_fork函数被调用之前被调用,该函数仅仅是打印了被探测点的地址,保存的个别寄存器参数。由于受CPU架构影响,这里对不同的架构进行了宏区分 handler_post回调函数的前两个入参同handler_pre,第三个参数目...
在X86_64平台上,Linux的参数传递通过如下9个寄存器完成,分别为:RDI,RSI,RDX,RCX,RAX,R8,R9,R10,R11。在pre_handler函数中,我们可以得到寄存器组变量,通过寄存器组变量我们可以通过RSI寄存器得到create_empty_buffers函数传入的第二个参数值。对于Linux-2.6.23版本,函数调用过程中寄存器在栈中布局定义如下: struct pt...
它通过kprobe的pre_handler回调判断,如果是aggregator则它的pre_handler回调函数会被替换成aggr_pre_handler函数。一般对于第二次注册kprobe的情况显然是不会满足条件的,会调用alloc_aggr_kprobe函数创建一个,对于没有开启CONFIG_OPTPROBES选项的情况,alloc_aggr_kprobe仅仅是分配了一块内存空间,然后调用init_aggr_kprobe函...
};/* kprobe pre_handler: called just before the probed instruction is executed */staticinthandler_pre(structkprobe *p,structpt_regs *regs){pr_info("<%s> pre_handler: p->addr = 0x%p, pc = 0x%lx,"" pstate = 0x%lx\n", p->symbol_name, p->addr, (long)regs->pc, (long)regs-...
a kprobe structure */staticstructkprobe kp={.symbol_name=symbol,};/* kprobe pre_handler: called just before the probed instruction is executed */staticinthandler_pre(structkprobe*p,structpt_regs*regs){#ifdef CONFIG_X86// rdi,rsi,rdx,rcx,r8,r9,寄存器传参及顺序,dentry在第二个参数,所以用rsi...
我有一个自定义内核模块,我需要一个新的函数添加kprobe来监控do_execveat_common函数 ,获取进程的启动参数我的代码如下static int my_kprobe_pre_handler_dynamic(struct kprobe *p, struct pt_regs *regs){//获取进程的可执行文件路径struct filename *filename = (struct filename *)PT_REGS_PARM2(regs);...
kprobe_fault_handler_t fault_handler://在执行pre_handler、post_handler或单步执行被探测指令时出现内存异常则会调用该回调函数; kprobe_break_handler_t break_handler://在执行某一kprobe过程中触发了断点指令后会调用该函数,用于实现jprobe; kprobe_opcode_t opcode://保存的被探测点原始指令;structarch_specifi...