| 1 |
# fanotify_init ______________________________________________ |
| 2 |
# fanotify_init() was enabled in kernel version 2.6.37. |
| 3 |
# SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, |
| 4 |
# unsigned int, event_f_flags) |
| 5 |
|
| 6 |
@define _SYSCALL_FANOTIFY_INIT_NAME |
| 7 |
%( |
| 8 |
name = "fanotify_init" |
| 9 |
%) |
| 10 |
|
| 11 |
@define _SYSCALL_FANOTIFY_INIT_ARGSTR |
| 12 |
%( |
| 13 |
argstr = sprintf("%s, %s", flags_str, event_f_flags_str) |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_FANOTIFY_INIT_REGARGS |
| 17 |
%( |
| 18 |
flags = uint_arg(1) |
| 19 |
flags_str = _fanotify_init_flags_str(flags) |
| 20 |
event_f_flags = uint_arg(2) |
| 21 |
event_f_flags_str = _sys_open_flag_str(event_f_flags) |
| 22 |
%) |
| 23 |
|
| 24 |
@define _SYSCALL_FANOTIFY_INIT_REGARGS_STORE |
| 25 |
%( |
| 26 |
if (@probewrite(flags)) |
| 27 |
set_uint_arg(1, flags) |
| 28 |
|
| 29 |
if (@probewrite(event_f_flags)) |
| 30 |
set_uint_arg(2, event_f_flags) |
| 31 |
%) |
| 32 |
|
| 33 |
probe syscall.fanotify_init = dw_syscall.fanotify_init !, nd_syscall.fanotify_init ? {} |
| 34 |
probe syscall.fanotify_init.return = dw_syscall.fanotify_init.return !, nd_syscall.fanotify_init.return ? {} |
| 35 |
|
| 36 |
# dw_fanotify_init _____________________________________________________ |
| 37 |
|
| 38 |
probe dw_syscall.fanotify_init = kernel.function("sys_fanotify_init").call ? |
| 39 |
{ |
| 40 |
@_SYSCALL_FANOTIFY_INIT_NAME |
| 41 |
flags = __uint32($flags) |
| 42 |
flags_str = _fanotify_init_flags_str(flags) |
| 43 |
event_f_flags = __uint32($event_f_flags) |
| 44 |
event_f_flags_str = _sys_open_flag_str(event_f_flags) |
| 45 |
@_SYSCALL_FANOTIFY_INIT_ARGSTR |
| 46 |
} |
| 47 |
probe dw_syscall.fanotify_init.return = |
| 48 |
kernel.function("sys_fanotify_init").return ? |
| 49 |
{ |
| 50 |
@_SYSCALL_FANOTIFY_INIT_NAME |
| 51 |
@SYSC_RETVALSTR($return) |
| 52 |
} |
| 53 |
|
| 54 |
# nd_fanotify_init _____________________________________________________ |
| 55 |
|
| 56 |
probe nd_syscall.fanotify_init = nd1_syscall.fanotify_init!, nd2_syscall.fanotify_init!, tp_syscall.fanotify_init |
| 57 |
{ } |
| 58 |
|
| 59 |
probe nd1_syscall.fanotify_init = kprobe.function("sys_fanotify_init") ? |
| 60 |
{ |
| 61 |
@_SYSCALL_FANOTIFY_INIT_NAME |
| 62 |
asmlinkage() |
| 63 |
@_SYSCALL_FANOTIFY_INIT_REGARGS |
| 64 |
@_SYSCALL_FANOTIFY_INIT_ARGSTR |
| 65 |
} |
| 66 |
|
| 67 |
/* kernel 4.17+ */ |
| 68 |
probe nd2_syscall.fanotify_init = kprobe.function(@arch_syscall_prefix "sys_fanotify_init") ? |
| 69 |
{ |
| 70 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 71 |
@_SYSCALL_FANOTIFY_INIT_NAME |
| 72 |
@_SYSCALL_FANOTIFY_INIT_REGARGS |
| 73 |
@_SYSCALL_FANOTIFY_INIT_ARGSTR |
| 74 |
}, |
| 75 |
{ |
| 76 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_FANOTIFY_INIT_REGARGS_STORE %) |
| 77 |
} |
| 78 |
|
| 79 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 80 |
probe tp_syscall.fanotify_init = kernel.trace("sys_enter") |
| 81 |
{ |
| 82 |
__set_syscall_pt_regs($regs) |
| 83 |
@__syscall_compat_gate(@const("__NR_fanotify_init"), @const("__NR_compat_fanotify_init")) |
| 84 |
@_SYSCALL_FANOTIFY_INIT_NAME |
| 85 |
@_SYSCALL_FANOTIFY_INIT_REGARGS |
| 86 |
@_SYSCALL_FANOTIFY_INIT_ARGSTR |
| 87 |
}, |
| 88 |
{ |
| 89 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_FANOTIFY_INIT_REGARGS_STORE %) |
| 90 |
} |
| 91 |
|
| 92 |
probe nd_syscall.fanotify_init.return = nd1_syscall.fanotify_init.return!, nd2_syscall.fanotify_init.return!, tp_syscall.fanotify_init.return |
| 93 |
{ } |
| 94 |
|
| 95 |
probe nd1_syscall.fanotify_init.return = |
| 96 |
kprobe.function("sys_fanotify_init").return ? |
| 97 |
{ |
| 98 |
@_SYSCALL_FANOTIFY_INIT_NAME |
| 99 |
@SYSC_RETVALSTR(returnval()) |
| 100 |
} |
| 101 |
|
| 102 |
/* kernel 4.17+ */ |
| 103 |
probe nd2_syscall.fanotify_init.return = kprobe.function(@arch_syscall_prefix "sys_fanotify_init").return ? |
| 104 |
{ |
| 105 |
@_SYSCALL_FANOTIFY_INIT_NAME |
| 106 |
@SYSC_RETVALSTR(returnval()) |
| 107 |
} |
| 108 |
|
| 109 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 110 |
probe tp_syscall.fanotify_init.return = kernel.trace("sys_exit") |
| 111 |
{ |
| 112 |
__set_syscall_pt_regs($regs) |
| 113 |
@__syscall_compat_gate(@const("__NR_fanotify_init"), @const("__NR_compat_fanotify_init")) |
| 114 |
@_SYSCALL_FANOTIFY_INIT_NAME |
| 115 |
@SYSC_RETVALSTR($ret) |
| 116 |
} |