관리-도구
편집 파일: sysc_kill.stp
# kill _______________________________________________________ # long sys_kill(int pid, int sig) @define _SYSCALL_KILL_NAME %( name = "kill" %) @define _SYSCALL_KILL_ARGSTR %( argstr = sprintf("%d, %s", pid, sig_name) %) @define _SYSCALL_KILL_REGARGS %( pid = int_arg(1) sig = int_arg(2) sig_name = _signal_name(sig) %) probe syscall.kill = dw_syscall.kill !, nd_syscall.kill ? {} probe syscall.kill.return = dw_syscall.kill.return !, nd_syscall.kill.return ? {} # dw_kill _____________________________________________________ probe dw_syscall.kill = kernel.function("sys_kill").call { @_SYSCALL_KILL_NAME pid = __int32($pid) sig = __int32($sig) sig_name = _signal_name(sig) @_SYSCALL_KILL_ARGSTR } probe dw_syscall.kill.return = kernel.function("sys_kill").return { @_SYSCALL_KILL_NAME @SYSC_RETVALSTR($return) } # nd_kill _____________________________________________________ probe nd_syscall.kill = nd1_syscall.kill!, nd2_syscall.kill!, tp_syscall.kill { } probe nd1_syscall.kill = kprobe.function("sys_kill") ? { @_SYSCALL_KILL_NAME asmlinkage() @_SYSCALL_KILL_REGARGS @_SYSCALL_KILL_ARGSTR } /* kernel 4.17+ */ probe nd2_syscall.kill = kprobe.function(@arch_syscall_prefix "sys_kill") ? { __set_syscall_pt_regs(pointer_arg(1)) @_SYSCALL_KILL_NAME @_SYSCALL_KILL_REGARGS @_SYSCALL_KILL_ARGSTR } /* kernel 3.5+, but undesirable because it affects all syscalls */ probe tp_syscall.kill = kernel.trace("sys_enter") { __set_syscall_pt_regs($regs) @__syscall_compat_gate(@const("__NR_kill"), @const("__NR_compat_kill")) @_SYSCALL_KILL_NAME @_SYSCALL_KILL_REGARGS @_SYSCALL_KILL_ARGSTR } probe nd_syscall.kill.return = nd1_syscall.kill.return!, nd2_syscall.kill.return!, tp_syscall.kill.return { } probe nd1_syscall.kill.return = kprobe.function("sys_kill").return ? { @_SYSCALL_KILL_NAME @SYSC_RETVALSTR(returnval()) } /* kernel 4.17+ */ probe nd2_syscall.kill.return = kprobe.function(@arch_syscall_prefix "sys_kill").return ? { @_SYSCALL_KILL_NAME @SYSC_RETVALSTR(returnval()) } /* kernel 3.5+, but undesirable because it affects all syscalls */ probe tp_syscall.kill.return = kernel.trace("sys_exit") { __set_syscall_pt_regs($regs) @__syscall_compat_gate(@const("__NR_kill"), @const("__NR_compat_kill")) @_SYSCALL_KILL_NAME @SYSC_RETVALSTR($ret) }