| 1 |
# mq_timedreceive ____________________________________________ |
| 2 |
# ssize_t sys_mq_timedreceive(mqd_t mqdes, |
| 3 |
# char __user *u_msg_ptr, |
| 4 |
# size_t msg_len, |
| 5 |
# unsigned int __user *u_msg_prio, |
| 6 |
# const struct timespec __user *u_abs_timeout) |
| 7 |
# ssize_t compat_sys_mq_timedreceive(mqd_t mqdes, |
| 8 |
# char __user *u_msg_ptr, |
| 9 |
# size_t msg_len, unsigned int __user *u_msg_prio, |
| 10 |
# const struct compat_timespec __user *u_abs_timeout) |
| 11 |
# |
| 12 |
|
| 13 |
@define _SYSCALL_MQ_TIMEDRECEIVE_NAME |
| 14 |
%( |
| 15 |
name = "mq_timedreceive" |
| 16 |
%) |
| 17 |
|
| 18 |
@define _SYSCALL_MQ_TIMEDRECEIVE_ARGSTR |
| 19 |
%( |
| 20 |
argstr = sprintf("%d, %p, %u, %p, %p", mqdes, msg_ptr_uaddr, msg_len, |
| 21 |
msg_prio_uaddr, abs_timeout_uaddr) |
| 22 |
%) |
| 23 |
|
| 24 |
@define _SYSCALL_MQ_TIMEDRECEIVE_REGARGS |
| 25 |
%( |
| 26 |
mqdes = int_arg(1) |
| 27 |
msg_ptr_uaddr = pointer_arg(2) |
| 28 |
msg_prio_uaddr = pointer_arg(4) |
| 29 |
abs_timeout_uaddr = pointer_arg(5) |
| 30 |
%) |
| 31 |
|
| 32 |
@define _SYSCALL_MQ_TIMEDRECEIVE_REGARGS_STORE |
| 33 |
%( |
| 34 |
if (@probewrite(mqdes)) |
| 35 |
set_int_arg(1, mqdes) |
| 36 |
|
| 37 |
if (@probewrite(msg_ptr_uaddr)) |
| 38 |
set_pointer_arg(2, msg_ptr_uaddr) |
| 39 |
|
| 40 |
if (@probewrite(msg_prio_uaddr)) |
| 41 |
set_pointer_arg(4, msg_prio_uaddr) |
| 42 |
|
| 43 |
if (@probewrite(abs_timeout_uaddr)) |
| 44 |
set_pointer_arg(5, abs_timeout_uaddr) |
| 45 |
%) |
| 46 |
|
| 47 |
probe syscall.mq_timedreceive = dw_syscall.mq_timedreceive !, nd_syscall.mq_timedreceive ? {} |
| 48 |
probe syscall.mq_timedreceive.return = dw_syscall.mq_timedreceive.return !, |
| 49 |
nd_syscall.mq_timedreceive.return ? {} |
| 50 |
|
| 51 |
# dw_mq_timedreceive _____________________________________________________ |
| 52 |
|
| 53 |
probe dw_syscall.mq_timedreceive = |
| 54 |
__syscall.mq_timedreceive ?, |
| 55 |
kernel.function("compat_sys_mq_timedreceive").call ? |
| 56 |
{ |
| 57 |
@_SYSCALL_MQ_TIMEDRECEIVE_NAME |
| 58 |
mqdes = __int32($mqdes) |
| 59 |
msg_ptr_uaddr = @__pointer($u_msg_ptr) |
| 60 |
msg_prio_uaddr = @__pointer($u_msg_prio) |
| 61 |
abs_timeout_uaddr = @__pointer($u_abs_timeout) |
| 62 |
%( CONFIG_64BIT == "y" %? |
| 63 |
msg_len = @__compat_ulong($msg_len) |
| 64 |
%: |
| 65 |
msg_len = __uint32($msg_len) |
| 66 |
%) |
| 67 |
@_SYSCALL_MQ_TIMEDRECEIVE_ARGSTR |
| 68 |
} |
| 69 |
probe __syscall.mq_timedreceive = kernel.function("sys_mq_timedreceive").call |
| 70 |
{ |
| 71 |
@__syscall_gate(@const("__NR_mq_timedreceive")) |
| 72 |
} |
| 73 |
probe dw_syscall.mq_timedreceive.return = |
| 74 |
__syscall.mq_timedreceive.return, |
| 75 |
kernel.function("compat_sys_mq_timedreceive").return ? |
| 76 |
{ |
| 77 |
@_SYSCALL_MQ_TIMEDRECEIVE_NAME |
| 78 |
@SYSC_RETVALSTR($return) |
| 79 |
} |
| 80 |
probe __syscall.mq_timedreceive.return = kernel.function("sys_mq_timedreceive").return |
| 81 |
{ |
| 82 |
@__syscall_gate_compat_simple |
| 83 |
} |
| 84 |
|
| 85 |
# nd_mq_timedreceive _____________________________________________________ |
| 86 |
|
| 87 |
probe nd_syscall.mq_timedreceive = nd1_syscall.mq_timedreceive!, nd2_syscall.mq_timedreceive!, tp_syscall.mq_timedreceive |
| 88 |
{ } |
| 89 |
|
| 90 |
probe nd1_syscall.mq_timedreceive = |
| 91 |
__nd1_syscall.mq_timedreceive ?, |
| 92 |
__nd1_syscall.compat_mq_timedreceive ? |
| 93 |
{ |
| 94 |
@_SYSCALL_MQ_TIMEDRECEIVE_NAME |
| 95 |
asmlinkage() |
| 96 |
@_SYSCALL_MQ_TIMEDRECEIVE_REGARGS |
| 97 |
@_SYSCALL_MQ_TIMEDRECEIVE_ARGSTR |
| 98 |
} |
| 99 |
probe __nd1_syscall.compat_mq_timedreceive = kprobe.function("compat_sys_mq_timedreceive") |
| 100 |
{ |
| 101 |
asmlinkage() |
| 102 |
msg_len = uint_arg(3) |
| 103 |
} |
| 104 |
probe __nd1_syscall.mq_timedreceive = kprobe.function("sys_mq_timedreceive") |
| 105 |
{ |
| 106 |
asmlinkage() |
| 107 |
@__syscall_gate(@const("__NR_mq_timedreceive")) |
| 108 |
%( CONFIG_64BIT == "y" %? |
| 109 |
msg_len = ulong_arg(3) |
| 110 |
%: |
| 111 |
msg_len = uint_arg(3) |
| 112 |
%) |
| 113 |
} |
| 114 |
|
| 115 |
/* kernel 4.17+ */ |
| 116 |
probe nd2_syscall.mq_timedreceive = |
| 117 |
__nd2_syscall.mq_timedreceive ?, |
| 118 |
__nd2_syscall.compat_mq_timedreceive ? |
| 119 |
{ |
| 120 |
@_SYSCALL_MQ_TIMEDRECEIVE_NAME |
| 121 |
@_SYSCALL_MQ_TIMEDRECEIVE_REGARGS |
| 122 |
@_SYSCALL_MQ_TIMEDRECEIVE_ARGSTR |
| 123 |
} |
| 124 |
probe __nd2_syscall.compat_mq_timedreceive = kprobe.function(@arch_syscall_prefix "compat_sys_mq_timedreceive") ? |
| 125 |
{ |
| 126 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 127 |
msg_len = uint_arg(3) |
| 128 |
}, |
| 129 |
{ |
| 130 |
%( @_IS_SREG_KERNEL %? |
| 131 |
@_SYSCALL_MQ_TIMEDRECEIVE_REGARGS_STORE |
| 132 |
if (@probewrite(msg_len)) |
| 133 |
set_uint_arg(3, msg_len) |
| 134 |
%) |
| 135 |
} |
| 136 |
probe __nd2_syscall.mq_timedreceive = kprobe.function(@arch_syscall_prefix "sys_mq_timedreceive") ? |
| 137 |
{ |
| 138 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 139 |
msg_len = ulong_arg(3) |
| 140 |
}, |
| 141 |
{ |
| 142 |
%( @_IS_SREG_KERNEL %? |
| 143 |
@_SYSCALL_MQ_TIMEDRECEIVE_REGARGS_STORE |
| 144 |
if (@probewrite(msg_len)) |
| 145 |
set_ulong_arg(3, msg_len) |
| 146 |
%) |
| 147 |
} |
| 148 |
|
| 149 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 150 |
probe tp_syscall.mq_timedreceive = |
| 151 |
__tp_syscall.mq_timedreceive ?, |
| 152 |
__tp_syscall.compat_mq_timedreceive ? |
| 153 |
{ |
| 154 |
@_SYSCALL_MQ_TIMEDRECEIVE_NAME |
| 155 |
@_SYSCALL_MQ_TIMEDRECEIVE_REGARGS |
| 156 |
@_SYSCALL_MQ_TIMEDRECEIVE_ARGSTR |
| 157 |
} |
| 158 |
probe __tp_syscall.compat_mq_timedreceive = kernel.trace("sys_enter") |
| 159 |
{ |
| 160 |
__set_syscall_pt_regs($regs) |
| 161 |
@__compat_syscall_gate(@const("__NR_compat_mq_timedreceive")) |
| 162 |
msg_len = uint_arg(3) |
| 163 |
}, |
| 164 |
{ |
| 165 |
%( @_IS_SREG_KERNEL %? |
| 166 |
@_SYSCALL_MQ_TIMEDRECEIVE_REGARGS_STORE |
| 167 |
if (@probewrite(msg_len)) |
| 168 |
set_uint_arg(3, msg_len) |
| 169 |
%) |
| 170 |
} |
| 171 |
probe __tp_syscall.mq_timedreceive = kernel.trace("sys_enter") |
| 172 |
{ |
| 173 |
__set_syscall_pt_regs($regs) |
| 174 |
@__syscall_gate(@const("__NR_mq_timedreceive")) |
| 175 |
msg_len = ulong_arg(3) |
| 176 |
}, |
| 177 |
{ |
| 178 |
%( @_IS_SREG_KERNEL %? |
| 179 |
@_SYSCALL_MQ_TIMEDRECEIVE_REGARGS_STORE |
| 180 |
if (@probewrite(msg_len)) |
| 181 |
set_ulong_arg(3, msg_len) |
| 182 |
%) |
| 183 |
} |
| 184 |
|
| 185 |
probe nd_syscall.mq_timedreceive.return = nd1_syscall.mq_timedreceive.return!, nd2_syscall.mq_timedreceive.return!, tp_syscall.mq_timedreceive.return |
| 186 |
{ } |
| 187 |
|
| 188 |
probe nd1_syscall.mq_timedreceive.return = |
| 189 |
__nd1_syscall.mq_timedreceive.return ?, |
| 190 |
kprobe.function("compat_sys_mq_timedreceive").return ? |
| 191 |
{ |
| 192 |
@_SYSCALL_MQ_TIMEDRECEIVE_NAME |
| 193 |
@SYSC_RETVALSTR(returnval()) |
| 194 |
} |
| 195 |
probe __nd1_syscall.mq_timedreceive.return = kprobe.function("sys_mq_timedreceive").return |
| 196 |
{ |
| 197 |
@__syscall_gate(@const("__NR_mq_timedreceive")) |
| 198 |
} |
| 199 |
|
| 200 |
/* kernel 4.17+ */ |
| 201 |
probe nd2_syscall.mq_timedreceive.return = |
| 202 |
kprobe.function(@arch_syscall_prefix "sys_mq_timedreceive").return ?, |
| 203 |
kprobe.function(@arch_syscall_prefix "compat_sys_mq_timedreceive").return ? |
| 204 |
{ |
| 205 |
@_SYSCALL_MQ_TIMEDRECEIVE_NAME |
| 206 |
@SYSC_RETVALSTR(returnval()) |
| 207 |
} |
| 208 |
|
| 209 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 210 |
probe tp_syscall.mq_timedreceive.return = kernel.trace("sys_exit") |
| 211 |
{ |
| 212 |
__set_syscall_pt_regs($regs) |
| 213 |
@__syscall_compat_gate(@const("__NR_mq_timedreceive"), @const("__NR_compat_mq_timedreceive")) |
| 214 |
@_SYSCALL_MQ_TIMEDRECEIVE_NAME |
| 215 |
@SYSC_RETVALSTR($ret) |
| 216 |
} |