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