| 1 |
# tkill ______________________________________________________ |
| 2 |
# |
| 3 |
# asmlinkage long |
| 4 |
# sys_tkill(int pid, |
| 5 |
# int sig) |
| 6 |
# |
| 7 |
|
| 8 |
@define _SYSCALL_TKILL_NAME |
| 9 |
%( |
| 10 |
name = "tkill" |
| 11 |
%) |
| 12 |
|
| 13 |
@define _SYSCALL_TKILL_ARGSTR |
| 14 |
%( |
| 15 |
argstr = sprintf("%d, %s", pid, sig_str) |
| 16 |
%) |
| 17 |
|
| 18 |
@define _SYSCALL_TKILL_REGARGS |
| 19 |
%( |
| 20 |
pid = int_arg(1) |
| 21 |
sig = int_arg(2) |
| 22 |
sig_str = _signal_name(sig) |
| 23 |
%) |
| 24 |
|
| 25 |
@define _SYSCALL_TKILL_REGARGS_STORE |
| 26 |
%( |
| 27 |
if (@probewrite(pid)) |
| 28 |
set_int_arg(1, pid) |
| 29 |
|
| 30 |
if (@probewrite(sig)) |
| 31 |
set_int_arg(2, sig) |
| 32 |
%) |
| 33 |
|
| 34 |
probe syscall.tkill = dw_syscall.tkill !, nd_syscall.tkill ? {} |
| 35 |
probe syscall.tkill.return = dw_syscall.tkill.return !, |
| 36 |
nd_syscall.tkill.return ? {} |
| 37 |
|
| 38 |
# dw_tkill _____________________________________________________ |
| 39 |
|
| 40 |
probe dw_syscall.tkill = kernel.function("sys_tkill").call |
| 41 |
{ |
| 42 |
@_SYSCALL_TKILL_NAME |
| 43 |
pid = __int32($pid) |
| 44 |
sig = __int32($sig) |
| 45 |
sig_str = _signal_name(sig) |
| 46 |
@_SYSCALL_TKILL_ARGSTR |
| 47 |
} |
| 48 |
probe dw_syscall.tkill.return = kernel.function("sys_tkill").return |
| 49 |
{ |
| 50 |
@_SYSCALL_TKILL_NAME |
| 51 |
@SYSC_RETVALSTR($return) |
| 52 |
} |
| 53 |
|
| 54 |
# nd_tkill _____________________________________________________ |
| 55 |
|
| 56 |
probe nd_syscall.tkill = nd1_syscall.tkill!, nd2_syscall.tkill!, tp_syscall.tkill |
| 57 |
{ } |
| 58 |
|
| 59 |
probe nd1_syscall.tkill = kprobe.function("sys_tkill") ? |
| 60 |
{ |
| 61 |
@_SYSCALL_TKILL_NAME |
| 62 |
asmlinkage() |
| 63 |
@_SYSCALL_TKILL_REGARGS |
| 64 |
@_SYSCALL_TKILL_ARGSTR |
| 65 |
} |
| 66 |
|
| 67 |
/* kernel 4.17+ */ |
| 68 |
probe nd2_syscall.tkill = kprobe.function(@arch_syscall_prefix "sys_tkill") ? |
| 69 |
{ |
| 70 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 71 |
@_SYSCALL_TKILL_NAME |
| 72 |
@_SYSCALL_TKILL_REGARGS |
| 73 |
@_SYSCALL_TKILL_ARGSTR |
| 74 |
}, |
| 75 |
{ |
| 76 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_TKILL_REGARGS_STORE %) |
| 77 |
} |
| 78 |
|
| 79 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 80 |
probe tp_syscall.tkill = kernel.trace("sys_enter") |
| 81 |
{ |
| 82 |
__set_syscall_pt_regs($regs) |
| 83 |
@__syscall_compat_gate(@const("__NR_tkill"), @const("__NR_compat_tkill")) |
| 84 |
@_SYSCALL_TKILL_NAME |
| 85 |
@_SYSCALL_TKILL_REGARGS |
| 86 |
@_SYSCALL_TKILL_ARGSTR |
| 87 |
}, |
| 88 |
{ |
| 89 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_TKILL_REGARGS_STORE %) |
| 90 |
} |
| 91 |
|
| 92 |
probe nd_syscall.tkill.return = nd1_syscall.tkill.return!, nd2_syscall.tkill.return!, tp_syscall.tkill.return |
| 93 |
{ } |
| 94 |
|
| 95 |
probe nd1_syscall.tkill.return = kprobe.function("sys_tkill").return ? |
| 96 |
{ |
| 97 |
@_SYSCALL_TKILL_NAME |
| 98 |
@SYSC_RETVALSTR(returnval()) |
| 99 |
} |
| 100 |
|
| 101 |
/* kernel 4.17+ */ |
| 102 |
probe nd2_syscall.tkill.return = kprobe.function(@arch_syscall_prefix "sys_tkill").return ? |
| 103 |
{ |
| 104 |
@_SYSCALL_TKILL_NAME |
| 105 |
@SYSC_RETVALSTR(returnval()) |
| 106 |
} |
| 107 |
|
| 108 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 109 |
probe tp_syscall.tkill.return = kernel.trace("sys_exit") |
| 110 |
{ |
| 111 |
__set_syscall_pt_regs($regs) |
| 112 |
@__syscall_compat_gate(@const("__NR_tkill"), @const("__NR_compat_tkill")) |
| 113 |
@_SYSCALL_TKILL_NAME |
| 114 |
@SYSC_RETVALSTR($ret) |
| 115 |
} |