| 1 |
# shmctl _____________________________________________________ |
| 2 |
# |
| 3 |
# long sys_shmctl (int shmid, |
| 4 |
# int cmd, |
| 5 |
# struct shmid_ds __user *buf) |
| 6 |
# |
| 7 |
|
| 8 |
@define _SYSCALL_SHMCTL_NAME |
| 9 |
%( |
| 10 |
name = "shmctl" |
| 11 |
%) |
| 12 |
|
| 13 |
@define _SYSCALL_SHMCTL_ARGSTR |
| 14 |
%( |
| 15 |
argstr = sprintf("%d, %s, %p", shmid, cmd_str, buf_uaddr) |
| 16 |
%) |
| 17 |
|
| 18 |
@define _SYSCALL_SHMCTL_REGARGS |
| 19 |
%( |
| 20 |
shmid = int_arg(1) |
| 21 |
cmd = int_arg(2) |
| 22 |
cmd_str = _semctl_cmd(cmd) |
| 23 |
buf_uaddr = pointer_arg(3) |
| 24 |
%) |
| 25 |
|
| 26 |
@define _SYSCALL_SHMCTL_REGARGS_STORE |
| 27 |
%( |
| 28 |
if (@probewrite(shmid)) |
| 29 |
set_int_arg(1, shmid) |
| 30 |
|
| 31 |
if (@probewrite(cmd)) |
| 32 |
set_int_arg(2, cmd) |
| 33 |
|
| 34 |
if (@probewrite(buf_uaddr)) |
| 35 |
set_pointer_arg(3, buf_uaddr) |
| 36 |
%) |
| 37 |
|
| 38 |
@define _SYSCALL_COMPAT_SHMCTL_REGARGS_STORE |
| 39 |
%( |
| 40 |
if (@probewrite(shmid)) |
| 41 |
set_int_arg(2, shmid) |
| 42 |
|
| 43 |
if (@probewrite(cmd)) |
| 44 |
set_int_arg(3, cmd) |
| 45 |
|
| 46 |
if (@probewrite(buf_uaddr)) |
| 47 |
set_pointer_arg(5, buf_uaddr) |
| 48 |
%) |
| 49 |
|
| 50 |
probe syscall.shmctl = dw_syscall.shmctl !, nd_syscall.shmctl ? {} |
| 51 |
probe syscall.shmctl.return = dw_syscall.shmctl.return !, |
| 52 |
nd_syscall.shmctl.return ? {} |
| 53 |
|
| 54 |
# dw_shmctl _____________________________________________________ |
| 55 |
|
| 56 |
probe dw_syscall.shmctl = kernel.function("sys_shmctl").call ? |
| 57 |
{ |
| 58 |
#%( arch == "powerpc" || arch == "s390" %? |
| 59 |
@__syscall_gate_compat_simple |
| 60 |
#%) |
| 61 |
@_SYSCALL_SHMCTL_NAME |
| 62 |
shmid = __int32($shmid) |
| 63 |
cmd = __int32($cmd) |
| 64 |
cmd_str = _semctl_cmd(__int32($cmd)) |
| 65 |
buf_uaddr = $buf |
| 66 |
@_SYSCALL_SHMCTL_ARGSTR |
| 67 |
} |
| 68 |
probe dw_syscall.shmctl.return = kernel.function("sys_shmctl").return ? |
| 69 |
{ |
| 70 |
#%( arch == "powerpc" || arch == "s390" %? |
| 71 |
@__syscall_gate_compat_simple |
| 72 |
#%) |
| 73 |
@_SYSCALL_SHMCTL_NAME |
| 74 |
@SYSC_RETVALSTR($return) |
| 75 |
} |
| 76 |
|
| 77 |
# nd_shmctl _____________________________________________________ |
| 78 |
|
| 79 |
probe nd_syscall.shmctl = nd1_syscall.shmctl!, nd2_syscall.shmctl!, tp_syscall.shmctl |
| 80 |
{ } |
| 81 |
|
| 82 |
probe nd1_syscall.shmctl = kprobe.function("sys_shmctl") ? |
| 83 |
{ |
| 84 |
#%( arch == "powerpc" || arch == "s390" %? |
| 85 |
@__syscall_gate_compat_simple |
| 86 |
#%) |
| 87 |
@_SYSCALL_SHMCTL_NAME |
| 88 |
asmlinkage() |
| 89 |
@_SYSCALL_SHMCTL_REGARGS |
| 90 |
@_SYSCALL_SHMCTL_ARGSTR |
| 91 |
} |
| 92 |
|
| 93 |
/* kernel 4.17+ */ |
| 94 |
probe nd2_syscall.shmctl = kprobe.function(@arch_syscall_prefix "sys_shmctl") ? |
| 95 |
{ |
| 96 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 97 |
@_SYSCALL_SHMCTL_NAME |
| 98 |
@_SYSCALL_SHMCTL_REGARGS |
| 99 |
@_SYSCALL_SHMCTL_ARGSTR |
| 100 |
}, |
| 101 |
{ |
| 102 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SHMCTL_REGARGS_STORE %) |
| 103 |
} |
| 104 |
|
| 105 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 106 |
probe tp_syscall.shmctl = kernel.trace("sys_enter") |
| 107 |
{ |
| 108 |
__set_syscall_pt_regs($regs) |
| 109 |
@__syscall_gate(@const("__NR_shmctl")) |
| 110 |
@_SYSCALL_SHMCTL_NAME |
| 111 |
@_SYSCALL_SHMCTL_REGARGS |
| 112 |
@_SYSCALL_SHMCTL_ARGSTR |
| 113 |
}, |
| 114 |
{ |
| 115 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_SHMCTL_REGARGS_STORE %) |
| 116 |
} |
| 117 |
|
| 118 |
probe nd_syscall.shmctl.return = nd1_syscall.shmctl.return!, nd2_syscall.shmctl.return!, tp_syscall.shmctl.return |
| 119 |
{ } |
| 120 |
|
| 121 |
probe nd1_syscall.shmctl.return = kprobe.function("sys_shmctl").return ? |
| 122 |
{ |
| 123 |
#%( arch == "powerpc" || arch == "s390" %? |
| 124 |
@__syscall_gate_compat_simple |
| 125 |
#%) |
| 126 |
@_SYSCALL_SHMCTL_NAME |
| 127 |
@SYSC_RETVALSTR(returnval()) |
| 128 |
} |
| 129 |
|
| 130 |
/* kernel 4.17+ */ |
| 131 |
probe nd2_syscall.shmctl.return = kprobe.function(@arch_syscall_prefix "sys_shmctl").return ? |
| 132 |
{ |
| 133 |
@_SYSCALL_SHMCTL_NAME |
| 134 |
@SYSC_RETVALSTR(returnval()) |
| 135 |
} |
| 136 |
|
| 137 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 138 |
probe tp_syscall.shmctl.return = kernel.trace("sys_exit") |
| 139 |
{ |
| 140 |
__set_syscall_pt_regs($regs) |
| 141 |
@__syscall_gate(@const("__NR_shmctl")) |
| 142 |
@_SYSCALL_SHMCTL_NAME |
| 143 |
@SYSC_RETVALSTR($ret) |
| 144 |
} |
| 145 |
|
| 146 |
# compat_sys_shmctl ________________________________________ |
| 147 |
# |
| 148 |
# long compat_sys_shmctl(int first, int second, void __user *uptr) |
| 149 |
# |
| 150 |
|
| 151 |
probe syscall.compat_sys_shmctl = dw_syscall.compat_sys_shmctl !, |
| 152 |
nd_syscall.compat_sys_shmctl ? {} |
| 153 |
probe syscall.compat_sys_shmctl.return = dw_syscall.compat_sys_shmctl.return !, |
| 154 |
nd_syscall.compat_sys_shmctl.return ? {} |
| 155 |
|
| 156 |
# dw_compat_sys_shmctl _____________________________________________________ |
| 157 |
|
| 158 |
probe dw_syscall.compat_sys_shmctl = __syscall.compat_shmctl ?, |
| 159 |
__syscall.compat_ipc.shmctl ? |
| 160 |
{ |
| 161 |
@_SYSCALL_SHMCTL_NAME |
| 162 |
%( systemtap_v <= "2.5" %? |
| 163 |
first = @choose_defined($first, $shmid) |
| 164 |
second = @choose_defined($second, $cmd) |
| 165 |
uptr_uaddr = @choose_defined($uptr, $ptr) |
| 166 |
%) |
| 167 |
shmid = __int32(@choose_defined($first, $shmid)) |
| 168 |
cmd = __int32(@choose_defined($second, $cmd)) |
| 169 |
cmd_str = _semctl_cmd(__int32(@choose_defined($second, $cmd))) |
| 170 |
buf_uaddr = @choose_defined($uptr, $ptr) |
| 171 |
@_SYSCALL_SHMCTL_ARGSTR |
| 172 |
} |
| 173 |
probe __syscall.compat_shmctl = kernel.function("compat_sys_shmctl").call ? |
| 174 |
{ |
| 175 |
@__compat_syscall_gate(@const("__NR_compat_shmctl")) |
| 176 |
} |
| 177 |
probe __syscall.compat_ipc.shmctl = kernel.function("compat_sys_ipc").call ?, |
| 178 |
kernel.function("sys32_ipc").call ? |
| 179 |
{ |
| 180 |
if ($call != @const("SHMCTL")) next; |
| 181 |
} |
| 182 |
|
| 183 |
probe dw_syscall.compat_sys_shmctl.return = |
| 184 |
kernel.function("compat_sys_shmctl").return ?, |
| 185 |
__syscall.compat_ipc.shmctl.return ? |
| 186 |
{ |
| 187 |
@_SYSCALL_SHMCTL_NAME |
| 188 |
@SYSC_RETVALSTR($return) |
| 189 |
} |
| 190 |
probe __syscall.compat_ipc.shmctl.return = |
| 191 |
kernel.function("compat_sys_ipc").return ?, |
| 192 |
kernel.function("sys32_ipc").return ? |
| 193 |
{ |
| 194 |
if (@entry($call) != @const("SHMCTL")) next; |
| 195 |
} |
| 196 |
|
| 197 |
# nd_compat_sys_shmctl _____________________________________________________ |
| 198 |
|
| 199 |
probe nd_syscall.compat_sys_shmctl = nd1_syscall.compat_sys_shmctl!, nd2_syscall.compat_sys_shmctl!, tp_syscall.compat_sys_shmctl |
| 200 |
{ } |
| 201 |
|
| 202 |
probe nd1_syscall.compat_sys_shmctl = __nd1_syscall.compat_shmctl ?, |
| 203 |
__nd1_syscall.compat_ipc.shmctl ? |
| 204 |
{ |
| 205 |
@_SYSCALL_SHMCTL_NAME |
| 206 |
cmd_str = _semctl_cmd(cmd) |
| 207 |
@_SYSCALL_SHMCTL_ARGSTR |
| 208 |
} |
| 209 |
probe __nd1_syscall.compat_shmctl = kprobe.function("compat_sys_shmctl") ? |
| 210 |
{ |
| 211 |
@__compat_syscall_gate(@const("__NR_compat_shmctl")) |
| 212 |
%( systemtap_v <= "2.5" %? |
| 213 |
first = int_arg(1) |
| 214 |
second = int_arg(2) |
| 215 |
uptr_uaddr = pointer_arg(3) |
| 216 |
%) |
| 217 |
shmid = int_arg(1) |
| 218 |
cmd = int_arg(2) |
| 219 |
buf_uaddr = pointer_arg(3) |
| 220 |
} |
| 221 |
probe __nd1_syscall.compat_ipc.shmctl = kprobe.function("compat_sys_ipc") ?, |
| 222 |
kprobe.function("sys32_ipc") ? |
| 223 |
{ |
| 224 |
if (int_arg(1) != @const("SHMCTL")) next; |
| 225 |
%( systemtap_v <= "2.5" %? |
| 226 |
first = int_arg(2) |
| 227 |
second = int_arg(3) |
| 228 |
uptr_uaddr = pointer_arg(5) |
| 229 |
%) |
| 230 |
shmid = int_arg(2) |
| 231 |
cmd = int_arg(3) |
| 232 |
buf_uaddr = pointer_arg(5) |
| 233 |
} |
| 234 |
|
| 235 |
/* kernel 4.17+ */ |
| 236 |
probe nd2_syscall.compat_sys_shmctl = |
| 237 |
kprobe.function(@arch_syscall_prefix "compat_sys_ipc") ? |
| 238 |
{ |
| 239 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 240 |
if (int_arg(1) != @const("SHMCTL")) next; |
| 241 |
@_SYSCALL_SHMCTL_NAME |
| 242 |
shmid = int_arg(2) |
| 243 |
cmd = int_arg(3) |
| 244 |
cmd_str = _semctl_cmd(cmd) |
| 245 |
buf_uaddr = pointer_arg(5) |
| 246 |
@_SYSCALL_SHMCTL_ARGSTR |
| 247 |
}, |
| 248 |
{ |
| 249 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_COMPAT_SHMCTL_REGARGS_STORE %) |
| 250 |
} |
| 251 |
|
| 252 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 253 |
probe tp_syscall.compat_sys_shmctl = kernel.trace("sys_enter") |
| 254 |
{ |
| 255 |
__set_syscall_pt_regs($regs) |
| 256 |
@__compat_syscall_gate(@const("__NR_compat_ipc")) |
| 257 |
if (int_arg(1) != @const("SHMCTL")) next; |
| 258 |
@_SYSCALL_SHMCTL_NAME |
| 259 |
shmid = int_arg(2) |
| 260 |
cmd = int_arg(3) |
| 261 |
cmd_str = _semctl_cmd(cmd) |
| 262 |
buf_uaddr = pointer_arg(5) |
| 263 |
@_SYSCALL_SHMCTL_ARGSTR |
| 264 |
}, |
| 265 |
{ |
| 266 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_COMPAT_SHMCTL_REGARGS_STORE %) |
| 267 |
} |
| 268 |
|
| 269 |
probe nd_syscall.compat_sys_shmctl.return = nd1_syscall.compat_sys_shmctl.return!, nd2_syscall.compat_sys_shmctl.return!, tp_syscall.compat_sys_shmctl.return |
| 270 |
{ } |
| 271 |
|
| 272 |
probe nd1_syscall.compat_sys_shmctl.return = |
| 273 |
kprobe.function("compat_sys_shmctl").return ?, |
| 274 |
__nd1_syscall.compat_ipc.shmctl.return ? |
| 275 |
{ |
| 276 |
@_SYSCALL_SHMCTL_NAME |
| 277 |
@SYSC_RETVALSTR(returnval()) |
| 278 |
} |
| 279 |
probe __nd1_syscall.compat_ipc.shmctl.return = |
| 280 |
kprobe.function("compat_sys_ipc").return ?, |
| 281 |
kprobe.function("sys32_ipc").return ? |
| 282 |
{ |
| 283 |
if (@entry(int_arg(1)) != @const("SHMCTL")) next; |
| 284 |
} |
| 285 |
|
| 286 |
/* kernel 4.17+ */ |
| 287 |
probe nd2_syscall.compat_sys_shmctl.return = |
| 288 |
kprobe.function(@arch_syscall_prefix "compat_sys_ipc").return ? |
| 289 |
{ |
| 290 |
__set_syscall_pt_regs(@entry(pointer_arg(1))) |
| 291 |
if (int_arg(1) != @const("SHMCTL")) next; |
| 292 |
@_SYSCALL_SHMCTL_NAME |
| 293 |
@SYSC_RETVALSTR(returnval()) |
| 294 |
} |
| 295 |
|
| 296 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 297 |
probe tp_syscall.compat_sys_shmctl.return = kernel.trace("sys_exit") |
| 298 |
{ |
| 299 |
__set_syscall_pt_regs($regs) |
| 300 |
@__compat_syscall_gate(@const("__NR_compat_ipc")) |
| 301 |
if (int_arg(1) != @const("SHMCTL")) next; |
| 302 |
@_SYSCALL_SHMCTL_NAME |
| 303 |
@SYSC_RETVALSTR($ret) |
| 304 |
} |