| 1 |
# fstatat ____________________________________________________ |
| 2 |
# sys32_fstatat64(unsigned int dfd, char __user *filename, struct stat64_emu31 __user* statbuf, int flag) |
| 3 |
# long sys_newfstatat(int dfd, char __user *filename, struct stat __user *statbuf, int flag) |
| 4 |
# long sys_fstatat64(int dfd, char __user *filename, struct stat64 __user *statbuf, int flag) |
| 5 |
# long compat_sys_newfstatat(unsigned int dfd, char __user *filename, struct compat_stat __user *statbuf, int flag) |
| 6 |
|
| 7 |
@define _SYSCALL_FSTATAT_NAME |
| 8 |
%( |
| 9 |
name = "fstatat" |
| 10 |
%) |
| 11 |
|
| 12 |
@define _SYSCALL_FSTATAT_ARGSTR |
| 13 |
%( |
| 14 |
argstr = sprintf("%s, %s, %p, %s", dirfd_str, path, buf_uaddr, flags_str) |
| 15 |
%) |
| 16 |
|
| 17 |
@define _SYSCALL_FSTATAT_REGARGS |
| 18 |
%( |
| 19 |
dirfd = int_arg(1) |
| 20 |
dirfd_str = _dfd_str(dirfd) |
| 21 |
path = user_string_quoted(pointer_arg(2)) |
| 22 |
path_unquoted = user_string_nofault(pointer_arg(2)) |
| 23 |
buf_uaddr = pointer_arg(3) |
| 24 |
flags = int_arg(4) |
| 25 |
flags_str = _at_flag_str(flags) |
| 26 |
%) |
| 27 |
|
| 28 |
@define _SYSCALL_FSTATAT_REGARGS_STORE |
| 29 |
%( |
| 30 |
if (@probewrite(dirfd)) |
| 31 |
set_int_arg(1, dirfd) |
| 32 |
|
| 33 |
if (@probewrite(path_unquoted)) |
| 34 |
set_user_string_arg(pointer_arg(2), path_unquoted) |
| 35 |
|
| 36 |
if (@probewrite(buf_uaddr)) |
| 37 |
set_pointer_arg(3, buf_uaddr) |
| 38 |
|
| 39 |
if (@probewrite(flags)) |
| 40 |
set_int_arg(4, flags) |
| 41 |
%) |
| 42 |
|
| 43 |
probe syscall.fstatat = dw_syscall.fstatat !, nd_syscall.fstatat ? {} |
| 44 |
probe syscall.fstatat.return = dw_syscall.fstatat.return !, nd_syscall.fstatat.return ? {} |
| 45 |
|
| 46 |
# dw_fstatat _____________________________________________________ |
| 47 |
|
| 48 |
probe dw_syscall.fstatat = kernel.function("sys_fstatat64").call ?, |
| 49 |
kernel.function("sys_newfstatat").call ?, |
| 50 |
kernel.function("compat_sys_newfstatat").call ?, |
| 51 |
kernel.function("sys32_fstatat64").call ?, |
| 52 |
%( arch == "s390" %? |
| 53 |
kernel.function("compat_sys_s390_fstatat64").call ?, |
| 54 |
%) |
| 55 |
%( arch == "x86_64" %? |
| 56 |
kernel.function("compat_sys_x86_fstatat").call ?, |
| 57 |
%) |
| 58 |
kernel.function("sys32_fstatat").call ? |
| 59 |
{ |
| 60 |
@_SYSCALL_FSTATAT_NAME |
| 61 |
dirfd = __int32($dfd) |
| 62 |
dirfd_str = _dfd_str(__int32($dfd)) |
| 63 |
path = user_string_quoted($filename) |
| 64 |
buf_uaddr = $statbuf |
| 65 |
flags = __int32($flag) |
| 66 |
flags_str = _at_flag_str(__int32($flag)) |
| 67 |
@_SYSCALL_FSTATAT_ARGSTR |
| 68 |
} |
| 69 |
probe dw_syscall.fstatat.return = kernel.function("sys_fstatat64").return ?, |
| 70 |
kernel.function("sys_newfstatat").return ?, |
| 71 |
kernel.function("compat_sys_newfstatat").return ?, |
| 72 |
kernel.function("sys32_fstatat64").return ?, |
| 73 |
%( arch == "s390" %? |
| 74 |
kernel.function("compat_sys_s390_fstatat64").return ?, |
| 75 |
%) |
| 76 |
%( arch == "x86_64" %? |
| 77 |
kernel.function("compat_sys_x86_fstatat").return ?, |
| 78 |
%) |
| 79 |
kernel.function("sys32_fstatat").return ? |
| 80 |
{ |
| 81 |
@_SYSCALL_FSTATAT_NAME |
| 82 |
@SYSC_RETVALSTR($return) |
| 83 |
} |
| 84 |
|
| 85 |
# nd_fstatat _____________________________________________________ |
| 86 |
|
| 87 |
probe nd_syscall.fstatat = nd1_syscall.fstatat!, nd2_syscall.fstatat!, tp_syscall.fstatat |
| 88 |
{ } |
| 89 |
|
| 90 |
probe nd1_syscall.fstatat = kprobe.function("sys_fstatat64") ?, |
| 91 |
kprobe.function("sys_newfstatat") ?, |
| 92 |
kprobe.function("compat_sys_newfstatat") ?, |
| 93 |
kprobe.function("sys32_fstatat64") ?, |
| 94 |
%( arch == "s390" %? |
| 95 |
kprobe.function("compat_sys_s390_fstatat64") ?, |
| 96 |
%) |
| 97 |
%( arch == "x86_64" %? |
| 98 |
kprobe.function("compat_sys_x86_fstatat") ?, |
| 99 |
%) |
| 100 |
kprobe.function("sys32_fstatat") ? |
| 101 |
{ |
| 102 |
@_SYSCALL_FSTATAT_NAME |
| 103 |
asmlinkage() |
| 104 |
@_SYSCALL_FSTATAT_REGARGS |
| 105 |
@_SYSCALL_FSTATAT_ARGSTR |
| 106 |
} |
| 107 |
|
| 108 |
/* kernel 4.17+ */ |
| 109 |
probe nd2_syscall.fstatat = |
| 110 |
kprobe.function(@arch_syscall_prefix "sys_newfstatat") ?, |
| 111 |
kprobe.function(@arch_syscall_prefix "compat_sys_x86_fstatat") ? |
| 112 |
{ |
| 113 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 114 |
@_SYSCALL_FSTATAT_NAME |
| 115 |
@_SYSCALL_FSTATAT_REGARGS |
| 116 |
@_SYSCALL_FSTATAT_ARGSTR |
| 117 |
}, |
| 118 |
{ |
| 119 |
@_SYSCALL_FSTATAT_REGARGS_STORE |
| 120 |
} |
| 121 |
|
| 122 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 123 |
probe tp_syscall.fstatat = __tp_syscall.fstatat64, |
| 124 |
__tp_syscall.newfstatat |
| 125 |
{ |
| 126 |
__set_syscall_pt_regs($regs) |
| 127 |
@_SYSCALL_FSTATAT_NAME |
| 128 |
@_SYSCALL_FSTATAT_REGARGS |
| 129 |
@_SYSCALL_FSTATAT_ARGSTR |
| 130 |
}, |
| 131 |
{ |
| 132 |
@_SYSCALL_FSTATAT_REGARGS_STORE |
| 133 |
} |
| 134 |
|
| 135 |
probe __tp_syscall.fstatat64 = kernel.trace("sys_enter") |
| 136 |
{ |
| 137 |
@__syscall_compat_gate(@const("__NR_fstatat64"), @const("__NR_compat_fstatat64")) |
| 138 |
} |
| 139 |
probe __tp_syscall.newfstatat = kernel.trace("sys_enter") |
| 140 |
{ |
| 141 |
@__syscall_gate(@const("__NR_newfstatat")) |
| 142 |
} |
| 143 |
|
| 144 |
probe nd_syscall.fstatat.return = nd1_syscall.fstatat.return!, nd2_syscall.fstatat.return!, tp_syscall.fstatat.return |
| 145 |
{ } |
| 146 |
|
| 147 |
probe nd1_syscall.fstatat.return = kprobe.function("sys_fstatat64").return ?, |
| 148 |
kprobe.function("sys_newfstatat").return ?, |
| 149 |
kprobe.function("compat_sys_newfstatat").return ?, |
| 150 |
kprobe.function("sys32_fstatat64").return ?, |
| 151 |
%( arch == "s390" %? |
| 152 |
kprobe.function("compat_sys_s390_fstatat64").return ?, |
| 153 |
%) |
| 154 |
%( arch == "x86_64" %? |
| 155 |
kprobe.function("compat_sys_x86_fstatat").return ?, |
| 156 |
%) |
| 157 |
kprobe.function("sys32_fstatat").return ? |
| 158 |
{ |
| 159 |
@_SYSCALL_FSTATAT_NAME |
| 160 |
@SYSC_RETVALSTR(returnval()) |
| 161 |
} |
| 162 |
|
| 163 |
/* kernel 4.17+ */ |
| 164 |
probe nd2_syscall.fstatat.return = |
| 165 |
kprobe.function(@arch_syscall_prefix "sys_newfstatat").return ?, |
| 166 |
kprobe.function(@arch_syscall_prefix "compat_sys_x86_fstatat").return ? |
| 167 |
{ |
| 168 |
@_SYSCALL_FSTATAT_NAME |
| 169 |
@SYSC_RETVALSTR(returnval()) |
| 170 |
} |
| 171 |
|
| 172 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 173 |
probe tp_syscall.fstatat.return = __tp_syscall.fstatat64.return, |
| 174 |
__tp_syscall.newfstatat.return |
| 175 |
{ |
| 176 |
__set_syscall_pt_regs($regs) |
| 177 |
@_SYSCALL_FSTATAT_NAME |
| 178 |
@SYSC_RETVALSTR($ret) |
| 179 |
} |
| 180 |
probe __tp_syscall.fstatat64.return = kernel.trace("sys_exit") |
| 181 |
{ |
| 182 |
@__syscall_compat_gate(@const("__NR_fstatat64"), @const("__NR_compat_fstatat64")) |
| 183 |
} |
| 184 |
probe __tp_syscall.newfstatat.return = kernel.trace("sys_exit") |
| 185 |
{ |
| 186 |
@__syscall_gate(@const("__NR_newfstatat")) |
| 187 |
} |