| 1 |
# fanotify_mark ______________________________________________ |
| 2 |
# fanotify_mark() was enabled in kernel version 2.6.37. |
| 3 |
# |
| 4 |
# SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, |
| 5 |
# __u64, mask, int, dfd, |
| 6 |
# const char __user *, pathname) |
| 7 |
# COMPAT_SYSCALL_DEFINE6(fanotify_mark, |
| 8 |
# int, fanotify_fd, unsigned int, flags, |
| 9 |
# __u32, mask0, __u32, mask1, int, dfd, |
| 10 |
# const char __user *, pathname) |
| 11 |
|
| 12 |
@define _SYSCALL_FANOTIFY_MARK_NAME |
| 13 |
%( |
| 14 |
name = "fanotify_mark" |
| 15 |
%) |
| 16 |
|
| 17 |
@define _SYSCALL_FANOTIFY_MARK_ARGSTR |
| 18 |
%( |
| 19 |
argstr = sprintf("%d, %s, %s, %s, %s", fanotify_fd, flags_str, mask_str, |
| 20 |
dirfd_str, pathname) |
| 21 |
%) |
| 22 |
|
| 23 |
@define _SYSCALL_FANOTIFY_MARK_REGARGS |
| 24 |
%( |
| 25 |
fanotify_fd = int_arg(1) |
| 26 |
flags = uint_arg(2) |
| 27 |
%( CONFIG_64BIT == "y" %? |
| 28 |
mask = ulonglong_arg(3) |
| 29 |
dirfd = int_arg(4) |
| 30 |
pathname = user_string_quoted(pointer_arg(5)) |
| 31 |
pathname_unquoted = user_string_nofault(pointer_arg(5)) |
| 32 |
%: |
| 33 |
# On a 32-bit kernel, 'long long' arguments take the space of |
| 34 |
# 2 arguments, so we have to adjust the following argument |
| 35 |
# numbers. |
| 36 |
mask = ulonglong_arg(3) |
| 37 |
dirfd = int_arg(5) |
| 38 |
pathname = user_string_quoted(pointer_arg(6)) |
| 39 |
pathname_unquoted = user_string_nofault(pointer_arg(6)) |
| 40 |
%) |
| 41 |
%) |
| 42 |
|
| 43 |
@define _SYSCALL_FANOTIFY_MARK_REGARGS_STORE |
| 44 |
%( |
| 45 |
if (@probewrite(fanotify_fd)) |
| 46 |
set_int_arg(1, fanotify_fd) |
| 47 |
|
| 48 |
if (@probewrite(flags)) |
| 49 |
set_uint_arg(2, flags) |
| 50 |
|
| 51 |
%( CONFIG_64BIT == "y" %? |
| 52 |
if (@probewrite(mask)) |
| 53 |
set_ulonglong_arg(3, mask) |
| 54 |
|
| 55 |
if (@probewrite(dirfd)) |
| 56 |
set_int_arg(4, dirfd) |
| 57 |
|
| 58 |
if (@probewrite(pathname_unquoted)) |
| 59 |
set_user_string_arg(pointer_arg(5), pathname_unquoted) |
| 60 |
%: |
| 61 |
if (@probewrite(mask)) |
| 62 |
set_ulonglong_arg(3, mask) |
| 63 |
|
| 64 |
if (@probewrite(dirfd)) |
| 65 |
set_int_arg(5, dirfd) |
| 66 |
|
| 67 |
if (@probewrite(pathname_unquoted)) |
| 68 |
set_user_string_arg(pointer_arg(6), pathname_unquoted) |
| 69 |
%) |
| 70 |
%) |
| 71 |
|
| 72 |
@define _SYSCALL_COMPAT_FANOTIFY_MARK_REGARGS |
| 73 |
%( |
| 74 |
fanotify_fd = int_arg(1) |
| 75 |
flags = uint_arg(2) |
| 76 |
if (@__BIG_ENDIAN) |
| 77 |
mask = ((uint_arg(3) << 32) | uint_arg(4)) |
| 78 |
else |
| 79 |
mask = ((uint_arg(4) << 32) | uint_arg(3)) |
| 80 |
dirfd = int_arg(5) |
| 81 |
pathname = user_string_quoted(pointer_arg(6)) |
| 82 |
pathname_unquoted = user_string_nofault(pointer_arg(6)) |
| 83 |
%) |
| 84 |
|
| 85 |
@define _SYSCALL_COMPAT_FANOTIFY_MARK_REGARGS_STORE |
| 86 |
%( |
| 87 |
if (@probewrite(fanotify_fd)) |
| 88 |
set_int_arg(1, fanotify_fd) |
| 89 |
|
| 90 |
if (@probewrite(flags)) |
| 91 |
set_uint_arg(2, flags) |
| 92 |
|
| 93 |
if (@__BIG_ENDIAN) |
| 94 |
if (@probewrite(mask)) { |
| 95 |
set_uint_arg(3, mask >> 32) |
| 96 |
set_uint_arg(4, mask & 0xffffffff) |
| 97 |
} |
| 98 |
else |
| 99 |
if (@probewrite(mask)) { |
| 100 |
set_uint_arg(3, mask & 0xffffffff) |
| 101 |
set_uint_arg(4, mask >> 32) |
| 102 |
} |
| 103 |
|
| 104 |
if (@probewrite(dirfd)) |
| 105 |
set_int_arg(5, dirfd) |
| 106 |
|
| 107 |
if (@probewrite(pathname_unquoted)) |
| 108 |
set_user_string_arg(pointer_arg(6), pathname_unquoted) |
| 109 |
%) |
| 110 |
|
| 111 |
probe syscall.fanotify_mark = dw_syscall.fanotify_mark !, nd_syscall.fanotify_mark ? {} |
| 112 |
probe syscall.fanotify_mark.return = dw_syscall.fanotify_mark.return !, nd_syscall.fanotify_mark.return ? {} |
| 113 |
|
| 114 |
# dw_fanotify_mark _____________________________________________________ |
| 115 |
|
| 116 |
probe dw_syscall.fanotify_mark = __syscall.fanotify_mark ?, |
| 117 |
__syscall.compat_fanotify_mark ? |
| 118 |
{ |
| 119 |
@_SYSCALL_FANOTIFY_MARK_NAME |
| 120 |
flags_str = _fanotify_mark_flags_str(flags) |
| 121 |
mask_str = _fanotify_mark_mask_str(mask) |
| 122 |
dirfd_str = _dfd_str(dirfd) |
| 123 |
@_SYSCALL_FANOTIFY_MARK_ARGSTR |
| 124 |
} |
| 125 |
probe __syscall.fanotify_mark = kernel.function("sys_fanotify_mark").call ? |
| 126 |
{ |
| 127 |
@__syscall_gate_compat_simple |
| 128 |
fanotify_fd = __int32($fanotify_fd) |
| 129 |
flags = __uint32($flags) |
| 130 |
mask = $mask |
| 131 |
dirfd = __int32($dfd) |
| 132 |
pathname = user_string_quoted(@__pointer($pathname)) |
| 133 |
} |
| 134 |
probe __syscall.compat_fanotify_mark = |
| 135 |
kernel.function("compat_sys_fanotify_mark").call ? |
| 136 |
{ |
| 137 |
fanotify_fd = __int32($fanotify_fd) |
| 138 |
flags = __uint32($flags) |
| 139 |
if (@__BIG_ENDIAN) |
| 140 |
mask = ((__uint32($mask0) << 32) | __uint32($mask1)) |
| 141 |
else |
| 142 |
mask = ((__uint32($mask1) << 32) | __uint32($mask0)) |
| 143 |
dirfd = __int32($dfd) |
| 144 |
pathname = user_string_quoted(@__pointer($pathname)) |
| 145 |
} |
| 146 |
probe dw_syscall.fanotify_mark.return = |
| 147 |
kernel.function("sys_fanotify_mark").return ?, |
| 148 |
kernel.function("compat_sys_fanotify_mark").return ? |
| 149 |
{ |
| 150 |
@_SYSCALL_FANOTIFY_MARK_NAME |
| 151 |
@SYSC_RETVALSTR($return) |
| 152 |
} |
| 153 |
|
| 154 |
# nd_fanotify_mark _____________________________________________________ |
| 155 |
|
| 156 |
probe nd_syscall.fanotify_mark = nd1_syscall.fanotify_mark!, nd2_syscall.fanotify_mark!, tp_syscall.fanotify_mark |
| 157 |
{ } |
| 158 |
|
| 159 |
probe nd1_syscall.fanotify_mark = __nd1_syscall.fanotify_mark ?, |
| 160 |
__nd1_syscall.compat_fanotify_mark ? |
| 161 |
{ |
| 162 |
@_SYSCALL_FANOTIFY_MARK_NAME |
| 163 |
flags_str = _fanotify_mark_flags_str(flags) |
| 164 |
mask_str = _fanotify_mark_mask_str(mask) |
| 165 |
dirfd_str = _dfd_str(dirfd) |
| 166 |
@_SYSCALL_FANOTIFY_MARK_ARGSTR |
| 167 |
} |
| 168 |
probe __nd1_syscall.fanotify_mark = kprobe.function("sys_fanotify_mark") ? |
| 169 |
{ |
| 170 |
@__syscall_gate_compat_simple |
| 171 |
asmlinkage() |
| 172 |
@_SYSCALL_FANOTIFY_MARK_REGARGS |
| 173 |
} |
| 174 |
probe __nd1_syscall.compat_fanotify_mark = |
| 175 |
kprobe.function("compat_sys_fanotify_mark") ? |
| 176 |
{ |
| 177 |
asmlinkage() |
| 178 |
@_SYSCALL_COMPAT_FANOTIFY_MARK_REGARGS |
| 179 |
} |
| 180 |
|
| 181 |
/* kernel 4.17+ */ |
| 182 |
probe nd2_syscall.fanotify_mark = __nd2_syscall.fanotify_mark ?, |
| 183 |
__nd2_syscall.compat_fanotify_mark ? |
| 184 |
{ |
| 185 |
@_SYSCALL_FANOTIFY_MARK_NAME |
| 186 |
flags_str = _fanotify_mark_flags_str(flags) |
| 187 |
mask_str = _fanotify_mark_mask_str(mask) |
| 188 |
dirfd_str = _dfd_str(dirfd) |
| 189 |
@_SYSCALL_FANOTIFY_MARK_ARGSTR |
| 190 |
} |
| 191 |
probe __nd2_syscall.fanotify_mark = kprobe.function(@arch_syscall_prefix "sys_fanotify_mark") ? |
| 192 |
{ |
| 193 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 194 |
@_SYSCALL_FANOTIFY_MARK_REGARGS |
| 195 |
}, |
| 196 |
{ |
| 197 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_FANOTIFY_MARK_REGARGS_STORE %) |
| 198 |
} |
| 199 |
probe __nd2_syscall.compat_fanotify_mark = |
| 200 |
kprobe.function(@arch_syscall_prefix "compat_sys_fanotify_mark") ? |
| 201 |
{ |
| 202 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 203 |
@_SYSCALL_COMPAT_FANOTIFY_MARK_REGARGS |
| 204 |
}, |
| 205 |
{ |
| 206 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_COMPAT_FANOTIFY_MARK_REGARGS_STORE %) |
| 207 |
} |
| 208 |
|
| 209 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 210 |
probe tp_syscall.fanotify_mark = __tp_syscall.fanotify_mark ?, |
| 211 |
__tp_syscall.compat_fanotify_mark ? |
| 212 |
{ |
| 213 |
@_SYSCALL_FANOTIFY_MARK_NAME |
| 214 |
flags_str = _fanotify_mark_flags_str(flags) |
| 215 |
mask_str = _fanotify_mark_mask_str(mask) |
| 216 |
dirfd_str = _dfd_str(dirfd) |
| 217 |
@_SYSCALL_FANOTIFY_MARK_ARGSTR |
| 218 |
} |
| 219 |
probe __tp_syscall.fanotify_mark = kernel.trace("sys_enter") |
| 220 |
{ |
| 221 |
__set_syscall_pt_regs($regs) |
| 222 |
@__syscall_gate(@const("__NR_fanotify_mark")) |
| 223 |
@_SYSCALL_FANOTIFY_MARK_REGARGS |
| 224 |
}, |
| 225 |
{ |
| 226 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_FANOTIFY_MARK_REGARGS_STORE %) |
| 227 |
} |
| 228 |
probe __tp_syscall.compat_fanotify_mark = kernel.trace("sys_enter") |
| 229 |
{ |
| 230 |
__set_syscall_pt_regs($regs) |
| 231 |
@__compat_syscall_gate(@const("__NR_compat_fanotify_mark")) |
| 232 |
@_SYSCALL_COMPAT_FANOTIFY_MARK_REGARGS |
| 233 |
}, |
| 234 |
{ |
| 235 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_COMPAT_FANOTIFY_MARK_REGARGS_STORE %) |
| 236 |
} |
| 237 |
|
| 238 |
probe nd_syscall.fanotify_mark.return = nd1_syscall.fanotify_mark.return!, nd2_syscall.fanotify_mark.return!, tp_syscall.fanotify_mark.return |
| 239 |
{ } |
| 240 |
|
| 241 |
probe nd1_syscall.fanotify_mark.return = |
| 242 |
kprobe.function("sys_fanotify_mark").return ?, |
| 243 |
kprobe.function("compat_sys_fanotify_mark").return ? |
| 244 |
{ |
| 245 |
@_SYSCALL_FANOTIFY_MARK_NAME |
| 246 |
@SYSC_RETVALSTR(returnval()) |
| 247 |
} |
| 248 |
|
| 249 |
/* kernel 4.17+ */ |
| 250 |
probe nd2_syscall.fanotify_mark.return = |
| 251 |
kprobe.function(@arch_syscall_prefix "sys_fanotify_mark").return ?, |
| 252 |
kprobe.function(@arch_syscall_prefix "compat_sys_fanotify_mark").return ? |
| 253 |
{ |
| 254 |
@_SYSCALL_FANOTIFY_MARK_NAME |
| 255 |
@SYSC_RETVALSTR(returnval()) |
| 256 |
} |
| 257 |
|
| 258 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 259 |
probe tp_syscall.fanotify_mark.return = kernel.trace("sys_exit") |
| 260 |
{ |
| 261 |
__set_syscall_pt_regs($regs) |
| 262 |
@__syscall_compat_gate(@const("__NR_fanotify_mark"), @const("__NR_compat_fanotify_mark")) |
| 263 |
@_SYSCALL_FANOTIFY_MARK_NAME |
| 264 |
@SYSC_RETVALSTR($ret) |
| 265 |
} |