| 1 |
# mq_open ____________________________________________________ |
| 2 |
# long sys_mq_open(const char __user *u_name, |
| 3 |
# int oflag, |
| 4 |
# mode_t mode, |
| 5 |
# struct mq_attr __user *u_attr) |
| 6 |
# long compat_sys_mq_open(const char __user *u_name, |
| 7 |
# int oflag, compat_mode_t mode, |
| 8 |
# struct compat_mq_attr __user *u_attr) |
| 9 |
# |
| 10 |
|
| 11 |
@define _SYSCALL_MQ_OPEN_NAME |
| 12 |
%( |
| 13 |
name = "mq_open" |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_MQ_OPEN_ARGSTR |
| 17 |
%( |
| 18 |
if (oflag & @const("O_CREAT")) |
| 19 |
argstr = sprintf("%s, %s, %#o, %p", filename, oflag_str, mode, u_attr_uaddr) |
| 20 |
else |
| 21 |
argstr = sprintf("%s, %s", filename, oflag_str) |
| 22 |
%) |
| 23 |
|
| 24 |
@define _SYSCALL_MQ_OPEN_REGARGS |
| 25 |
%( |
| 26 |
name_uaddr = pointer_arg(1) |
| 27 |
filename = user_string_quoted(name_uaddr) |
| 28 |
filename_unquoted = user_string_nofault(pointer_arg(1)) |
| 29 |
u_attr_uaddr = pointer_arg(4) |
| 30 |
oflag = int_arg(2) |
| 31 |
oflag_str = _sys_open_flag_str(oflag) |
| 32 |
%) |
| 33 |
|
| 34 |
@define _SYSCALL_MQ_OPEN_REGARGS_STORE |
| 35 |
%( |
| 36 |
if (@probewrite(name_uaddr)) |
| 37 |
set_pointer_arg(1, name_uaddr) |
| 38 |
|
| 39 |
if (@probewrite(filename_unquoted)) |
| 40 |
set_user_string_arg(pointer_arg(1), filename_unquoted) |
| 41 |
|
| 42 |
if (@probewrite(oflag)) |
| 43 |
set_int_arg(2, oflag) |
| 44 |
|
| 45 |
if (@probewrite(mode)) |
| 46 |
set_uint_arg(3, mode) |
| 47 |
|
| 48 |
if (@probewrite(u_attr_uaddr)) |
| 49 |
set_pointer_arg(4, u_attr_uaddr) |
| 50 |
%) |
| 51 |
|
| 52 |
probe syscall.mq_open = dw_syscall.mq_open !, nd_syscall.mq_open ? {} |
| 53 |
probe syscall.mq_open.return = dw_syscall.mq_open.return !, nd_syscall.mq_open.return ? {} |
| 54 |
|
| 55 |
# dw_mq_open _____________________________________________________ |
| 56 |
|
| 57 |
probe dw_syscall.mq_open = __syscall.mq_open, |
| 58 |
kernel.function("compat_sys_mq_open").call ? |
| 59 |
{ |
| 60 |
@_SYSCALL_MQ_OPEN_NAME |
| 61 |
name_uaddr = @__pointer($u_name) |
| 62 |
filename = user_string_quoted(name_uaddr) |
| 63 |
u_attr_uaddr = @__pointer($u_attr) |
| 64 |
oflag = __int32($oflag) |
| 65 |
oflag_str = _sys_open_flag_str(oflag) |
| 66 |
mode = (@__compat_task ? __ushort($mode) : __uint32($mode)) |
| 67 |
@_SYSCALL_MQ_OPEN_ARGSTR |
| 68 |
} |
| 69 |
|
| 70 |
probe __syscall.mq_open = kernel.function("sys_mq_open").call |
| 71 |
{ |
| 72 |
@__syscall_gate_compat_simple |
| 73 |
} |
| 74 |
probe dw_syscall.mq_open.return = |
| 75 |
__syscall.mq_open.return, |
| 76 |
kernel.function("compat_sys_mq_open").return ? |
| 77 |
{ |
| 78 |
@_SYSCALL_MQ_OPEN_NAME |
| 79 |
@SYSC_RETVALSTR($return) |
| 80 |
} |
| 81 |
probe __syscall.mq_open.return = kernel.function("sys_mq_open").return |
| 82 |
{ |
| 83 |
@__syscall_gate(@const("__NR_mq_open")) |
| 84 |
} |
| 85 |
|
| 86 |
# nd_mq_open _____________________________________________________ |
| 87 |
|
| 88 |
probe nd_syscall.mq_open = nd1_syscall.mq_open!, nd2_syscall.mq_open!, tp_syscall.mq_open |
| 89 |
{ } |
| 90 |
|
| 91 |
probe nd1_syscall.mq_open = __nd1_syscall.mq_open, |
| 92 |
__nd1_syscall.compat_mq_open ? |
| 93 |
{ |
| 94 |
asmlinkage() |
| 95 |
@_SYSCALL_MQ_OPEN_NAME |
| 96 |
@_SYSCALL_MQ_OPEN_REGARGS |
| 97 |
@_SYSCALL_MQ_OPEN_ARGSTR |
| 98 |
} |
| 99 |
probe __nd1_syscall.mq_open = kprobe.function("sys_mq_open") |
| 100 |
{ |
| 101 |
asmlinkage() |
| 102 |
@__syscall_gate(@const("__NR_mq_open")) |
| 103 |
%( CONFIG_64BIT == "y" %? |
| 104 |
mode = uint_arg(3) |
| 105 |
%: |
| 106 |
mode = (uint_arg(3) & 0xffff) |
| 107 |
%) |
| 108 |
} |
| 109 |
probe __nd1_syscall.compat_mq_open = kprobe.function("compat_sys_mq_open") |
| 110 |
{ |
| 111 |
asmlinkage() |
| 112 |
mode = (uint_arg(3) & 0xffff) |
| 113 |
} |
| 114 |
|
| 115 |
/* kernel 4.17+ */ |
| 116 |
probe nd2_syscall.mq_open = __nd2_syscall.mq_open, |
| 117 |
__nd2_syscall.compat_mq_open ? |
| 118 |
{ |
| 119 |
@_SYSCALL_MQ_OPEN_NAME |
| 120 |
@_SYSCALL_MQ_OPEN_REGARGS |
| 121 |
@_SYSCALL_MQ_OPEN_ARGSTR |
| 122 |
} |
| 123 |
probe __nd2_syscall.mq_open = kprobe.function(@arch_syscall_prefix "sys_mq_open") |
| 124 |
{ |
| 125 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 126 |
mode = uint_arg(3) |
| 127 |
}, |
| 128 |
{ |
| 129 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_MQ_OPEN_REGARGS_STORE %) |
| 130 |
} |
| 131 |
probe __nd2_syscall.compat_mq_open = kprobe.function(@arch_syscall_prefix "compat_sys_mq_open") |
| 132 |
{ |
| 133 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 134 |
mode = (uint_arg(3) & 0xffff) |
| 135 |
}, |
| 136 |
{ |
| 137 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_MQ_OPEN_REGARGS_STORE %) |
| 138 |
} |
| 139 |
|
| 140 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 141 |
probe tp_syscall.mq_open = __tp_syscall.mq_open, |
| 142 |
__tp_syscall.compat_mq_open ? |
| 143 |
{ |
| 144 |
@_SYSCALL_MQ_OPEN_NAME |
| 145 |
@_SYSCALL_MQ_OPEN_REGARGS |
| 146 |
@_SYSCALL_MQ_OPEN_ARGSTR |
| 147 |
} |
| 148 |
probe __tp_syscall.mq_open = kernel.trace("sys_enter") |
| 149 |
{ |
| 150 |
__set_syscall_pt_regs($regs) |
| 151 |
@__syscall_gate(@const("__NR_mq_open")) |
| 152 |
mode = uint_arg(3) |
| 153 |
}, |
| 154 |
{ |
| 155 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_MQ_OPEN_REGARGS_STORE %) |
| 156 |
} |
| 157 |
probe __tp_syscall.compat_mq_open = kernel.trace("sys_enter") |
| 158 |
{ |
| 159 |
__set_syscall_pt_regs($regs) |
| 160 |
@__compat_syscall_gate(@const("__NR_compat_mq_open")) |
| 161 |
mode = (uint_arg(3) & 0xffff) |
| 162 |
}, |
| 163 |
{ |
| 164 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_MQ_OPEN_REGARGS_STORE %) |
| 165 |
} |
| 166 |
|
| 167 |
probe nd_syscall.mq_open.return = nd1_syscall.mq_open.return!, nd2_syscall.mq_open.return!, tp_syscall.mq_open.return |
| 168 |
{ } |
| 169 |
|
| 170 |
probe nd1_syscall.mq_open.return = |
| 171 |
__nd1_syscall.mq_open.return ?, |
| 172 |
kprobe.function("compat_sys_mq_open").return ? |
| 173 |
{ |
| 174 |
@_SYSCALL_MQ_OPEN_NAME |
| 175 |
@SYSC_RETVALSTR(returnval()) |
| 176 |
} |
| 177 |
probe __nd1_syscall.mq_open.return = kprobe.function("sys_mq_open").return |
| 178 |
{ |
| 179 |
@__syscall_gate(@const("__NR_mq_open")) |
| 180 |
} |
| 181 |
|
| 182 |
/* kernel 4.17+ */ |
| 183 |
probe nd2_syscall.mq_open.return = |
| 184 |
kprobe.function(@arch_syscall_prefix "sys_mq_open").return ?, |
| 185 |
kprobe.function(@arch_syscall_prefix "compat_sys_mq_open").return ? |
| 186 |
{ |
| 187 |
@_SYSCALL_MQ_OPEN_NAME |
| 188 |
@SYSC_RETVALSTR(returnval()) |
| 189 |
} |
| 190 |
|
| 191 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 192 |
probe tp_syscall.mq_open.return = kernel.trace("sys_exit") |
| 193 |
{ |
| 194 |
__set_syscall_pt_regs($regs) |
| 195 |
@__syscall_compat_gate(@const("__NR_mq_open"), @const("__NR_compat_mq_open")) |
| 196 |
@_SYSCALL_MQ_OPEN_NAME |
| 197 |
@SYSC_RETVALSTR($ret) |
| 198 |
} |