| 1 |
# sigaction __________________________________________________ |
| 2 |
# sys_sigaction(int sig, const struct old_sigaction __user *act, struct old_sigaction __user *oact) |
| 3 |
# sys32_sigaction(int sig, struct old_sigaction32 __user *act, struct old_sigaction32 __user *oact) |
| 4 |
# |
| 5 |
|
| 6 |
@define _SYSCALL_SIGACTION_NAME |
| 7 |
%( |
| 8 |
name = "sigaction" |
| 9 |
%) |
| 10 |
|
| 11 |
@define _SYSCALL_SIGACTION_ARGSTR |
| 12 |
%( |
| 13 |
argstr = sprintf("%s, {%s}, %p", sig_str, act_str, oact_uaddr) |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_SIGACTION_REGARGS |
| 17 |
%( |
| 18 |
sig = int_arg(1) |
| 19 |
sig_str = _signal_name(sig) |
| 20 |
act_uaddr = pointer_arg(2) |
| 21 |
act_str = _struct_sigaction_u(act_uaddr) |
| 22 |
oact_uaddr = pointer_arg(3) |
| 23 |
%) |
| 24 |
|
| 25 |
@define _SYSCALL_SIGACTION_REGARGS_STORE |
| 26 |
%( |
| 27 |
if (@probewrite(sig)) |
| 28 |
set_int_arg(1, sig) |
| 29 |
|
| 30 |
if (@probewrite(act_uaddr)) |
| 31 |
set_pointer_arg(2, act_uaddr) |
| 32 |
|
| 33 |
if (@probewrite(oact_uaddr)) |
| 34 |
set_pointer_arg(3, oact_uaddr) |
| 35 |
%) |
| 36 |
|
| 37 |
@define _SYSCALL_SIGACTION32_REGARGS |
| 38 |
%( |
| 39 |
sig = int_arg(1) |
| 40 |
sig_str = _signal_name(sig) |
| 41 |
act_uaddr = pointer_arg(2) |
| 42 |
act_str = _struct_old_sigaction32_u(act_uaddr) |
| 43 |
oact_uaddr = pointer_arg(3) |
| 44 |
%) |
| 45 |
|
| 46 |
probe syscall.sigaction32 = dw_syscall.sigaction32 !, nd_syscall.sigaction32 ? {} |
| 47 |
|
| 48 |
probe syscall.sigaction = dw_syscall.sigaction !, nd_syscall.sigaction ? {} |
| 49 |
probe syscall.sigaction.return = dw_syscall.sigaction.return !, |
| 50 |
nd_syscall.sigaction.return ? {} |
| 51 |
|
| 52 |
# dw_sigaction _____________________________________________________ |
| 53 |
|
| 54 |
probe dw_syscall.sigaction = kernel.function("sys_sigaction").call ? |
| 55 |
{ |
| 56 |
@_SYSCALL_SIGACTION_NAME |
| 57 |
sig = __int32($sig) |
| 58 |
sig_str = _signal_name(sig) |
| 59 |
act_uaddr = @__pointer($act) |
| 60 |
act_str = _struct_sigaction_u(act_uaddr) |
| 61 |
oact_uaddr = $oact |
| 62 |
@_SYSCALL_SIGACTION_ARGSTR |
| 63 |
} |
| 64 |
probe dw_syscall.sigaction.return = kernel.function("sys_sigaction").return ? |
| 65 |
{ |
| 66 |
@_SYSCALL_SIGACTION_NAME |
| 67 |
@SYSC_RETVALSTR($return) |
| 68 |
} |
| 69 |
|
| 70 |
# nd_sigaction _____________________________________________________ |
| 71 |
|
| 72 |
probe nd_syscall.sigaction = nd1_syscall.sigaction!, tp_syscall.sigaction |
| 73 |
{ } |
| 74 |
|
| 75 |
probe nd1_syscall.sigaction = kprobe.function("sys_sigaction") ? |
| 76 |
{ |
| 77 |
@_SYSCALL_SIGACTION_NAME |
| 78 |
%( arch != "powerpc" %? asmlinkage() %) |
| 79 |
@_SYSCALL_SIGACTION_REGARGS |
| 80 |
@_SYSCALL_SIGACTION_ARGSTR |
| 81 |
} |
| 82 |
|
| 83 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 84 |
probe tp_syscall.sigaction = kernel.trace("sys_enter") |
| 85 |
{ |
| 86 |
__set_syscall_pt_regs($regs) |
| 87 |
@__syscall_gate(@const("__NR_sigaction")) |
| 88 |
@_SYSCALL_SIGACTION_NAME |
| 89 |
@_SYSCALL_SIGACTION_REGARGS |
| 90 |
@_SYSCALL_SIGACTION_ARGSTR |
| 91 |
}, |
| 92 |
{ |
| 93 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SIGACTION_REGARGS_STORE %) |
| 94 |
} |
| 95 |
|
| 96 |
probe nd_syscall.sigaction.return = nd1_syscall.sigaction.return!, tp_syscall.sigaction.return |
| 97 |
{ } |
| 98 |
|
| 99 |
probe nd1_syscall.sigaction.return = kprobe.function("sys_sigaction").return ? |
| 100 |
{ |
| 101 |
@_SYSCALL_SIGACTION_NAME |
| 102 |
@SYSC_RETVALSTR(returnval()) |
| 103 |
} |
| 104 |
|
| 105 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 106 |
probe tp_syscall.sigaction.return = kernel.trace("sys_exit") |
| 107 |
{ |
| 108 |
__set_syscall_pt_regs($regs) |
| 109 |
@__syscall_gate(@const("__NR_sigaction")) |
| 110 |
@_SYSCALL_SIGACTION_NAME |
| 111 |
@SYSC_RETVALSTR($ret) |
| 112 |
} |
| 113 |
|
| 114 |
# sigaction _________________________________________________________ |
| 115 |
|
| 116 |
probe syscall.sigaction32.return = dw_syscall.sigaction32.return !, |
| 117 |
nd_syscall.sigaction32.return ? {} |
| 118 |
|
| 119 |
# dw_sigaction32 _____________________________________________________ |
| 120 |
|
| 121 |
probe dw_syscall.sigaction32 = kernel.function("sys32_sigaction").call ?, |
| 122 |
kernel.function("compat_sys_sigaction").call ? |
| 123 |
{ |
| 124 |
@_SYSCALL_SIGACTION_NAME |
| 125 |
sig = __int32($sig) |
| 126 |
sig_str = _signal_name(sig) |
| 127 |
act_uaddr = @__pointer($act) |
| 128 |
act_str = _struct_old_sigaction32_u(act_uaddr) |
| 129 |
oact_uaddr = $oact |
| 130 |
@_SYSCALL_SIGACTION_ARGSTR |
| 131 |
} |
| 132 |
probe dw_syscall.sigaction32.return = kernel.function("sys32_sigaction").return ?, |
| 133 |
kernel.function("compat_sys_sigaction").return ? |
| 134 |
{ |
| 135 |
@_SYSCALL_SIGACTION_NAME |
| 136 |
@SYSC_RETVALSTR($return) |
| 137 |
} |
| 138 |
|
| 139 |
# nd_sigaction32 _____________________________________________________ |
| 140 |
|
| 141 |
probe nd_syscall.sigaction32 = nd1_syscall.sigaction32!, nd2_syscall.sigaction32!, tp_syscall.sigaction32 |
| 142 |
{ } |
| 143 |
|
| 144 |
probe nd1_syscall.sigaction32 = kprobe.function("sys32_sigaction") ?, |
| 145 |
kprobe.function("compat_sys_sigaction") ? |
| 146 |
{ |
| 147 |
@_SYSCALL_SIGACTION_NAME |
| 148 |
asmlinkage() |
| 149 |
@_SYSCALL_SIGACTION32_REGARGS |
| 150 |
@_SYSCALL_SIGACTION_ARGSTR |
| 151 |
} |
| 152 |
|
| 153 |
/* kernel 4.17+ */ |
| 154 |
probe nd2_syscall.sigaction32 = |
| 155 |
kprobe.function(@arch_syscall_prefix "compat_sys_sigaction") ? |
| 156 |
{ |
| 157 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 158 |
@_SYSCALL_SIGACTION_NAME |
| 159 |
@_SYSCALL_SIGACTION32_REGARGS |
| 160 |
@_SYSCALL_SIGACTION_ARGSTR |
| 161 |
}, |
| 162 |
{ |
| 163 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SIGACTION_REGARGS_STORE %) |
| 164 |
} |
| 165 |
|
| 166 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 167 |
probe tp_syscall.sigaction32 = kernel.trace("sys_enter") |
| 168 |
{ |
| 169 |
__set_syscall_pt_regs($regs) |
| 170 |
@__compat_syscall_gate(@const("__NR_compat_sigaction")) |
| 171 |
@_SYSCALL_SIGACTION_NAME |
| 172 |
@_SYSCALL_SIGACTION32_REGARGS |
| 173 |
@_SYSCALL_SIGACTION_ARGSTR |
| 174 |
}, |
| 175 |
{ |
| 176 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SIGACTION_REGARGS_STORE %) |
| 177 |
} |
| 178 |
|
| 179 |
probe nd_syscall.sigaction32.return = nd1_syscall.sigaction32.return!, nd2_syscall.sigaction32.return!, tp_syscall.sigaction32.return |
| 180 |
{ } |
| 181 |
|
| 182 |
probe nd1_syscall.sigaction32.return = kprobe.function("sys32_sigaction").return ?, |
| 183 |
kprobe.function("compat_sys_sigaction").return ? |
| 184 |
{ |
| 185 |
@_SYSCALL_SIGACTION_NAME |
| 186 |
@SYSC_RETVALSTR(returnval()) |
| 187 |
} |
| 188 |
|
| 189 |
/* kernel 4.17+ */ |
| 190 |
probe nd2_syscall.sigaction32.return = |
| 191 |
kprobe.function(@arch_syscall_prefix "compat_sys_sigaction").return ? |
| 192 |
{ |
| 193 |
@_SYSCALL_SIGACTION_NAME |
| 194 |
@SYSC_RETVALSTR(returnval()) |
| 195 |
} |
| 196 |
|
| 197 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 198 |
probe tp_syscall.sigaction32.return = kernel.trace("sys_exit") |
| 199 |
{ |
| 200 |
__set_syscall_pt_regs($regs) |
| 201 |
@__compat_syscall_gate(@const("__NR_compat_sigaction")) |
| 202 |
@_SYSCALL_SIGACTION_NAME |
| 203 |
@SYSC_RETVALSTR($ret) |
| 204 |
} |