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