| 1 |
# lstat ______________________________________________________ |
| 2 |
# long sys_lstat(char __user * filename, struct __old_kernel_stat __user * statbuf) |
| 3 |
# long sys_newlstat(char __user * filename, struct stat __user * statbuf) |
| 4 |
# long compat_sys_newlstat(char __user * filename, struct compat_stat __user *statbuf) |
| 5 |
# long sys32_lstat64(char * filename, struct stat64 __user *statbuf) |
| 6 |
# long sys_lstat64(char __user * filename, struct stat64 __user * statbuf) |
| 7 |
# long sys_oabi_lstat64(char __user * filename, |
| 8 |
# struct oldabi_stat64 __user * statbuf) |
| 9 |
# COMPAT_SYSCALL_DEFINE2(s390_lstat64, const char __user *, filename, struct stat64_emu31 __user *, statbuf) |
| 10 |
# |
| 11 |
|
| 12 |
@define _SYSCALL_LSTAT_NAME |
| 13 |
%( |
| 14 |
name = "lstat" |
| 15 |
%) |
| 16 |
|
| 17 |
@define _SYSCALL_LSTAT_ARGSTR |
| 18 |
%( |
| 19 |
argstr = sprintf("%s, %p", path, buf_uaddr) |
| 20 |
%) |
| 21 |
|
| 22 |
@define _SYSCALL_LSTAT_REGARGS |
| 23 |
%( |
| 24 |
path = user_string_quoted(pointer_arg(1)) |
| 25 |
path_unquoted = user_string_nofault(pointer_arg(1)) |
| 26 |
buf_uaddr = pointer_arg(2) |
| 27 |
%) |
| 28 |
|
| 29 |
@define _SYSCALL_LSTAT_REGARGS_STORE |
| 30 |
%( |
| 31 |
if (@probewrite(path_unquoted)) |
| 32 |
set_user_string_arg(pointer_arg(1), path_unquoted) |
| 33 |
|
| 34 |
if (@probewrite(buf_uaddr)) |
| 35 |
set_pointer_arg(2, buf_uaddr) |
| 36 |
%) |
| 37 |
|
| 38 |
probe syscall.lstat = dw_syscall.lstat !, nd_syscall.lstat ? {} |
| 39 |
probe syscall.lstat.return = dw_syscall.lstat.return !, |
| 40 |
nd_syscall.lstat.return ? {} |
| 41 |
|
| 42 |
# dw_lstat _____________________________________________________ |
| 43 |
|
| 44 |
probe dw_syscall.lstat = kernel.function("sys_lstat").call ?, |
| 45 |
kernel.function("sys_newlstat").call ?, |
| 46 |
kernel.function("compat_sys_newlstat").call ?, |
| 47 |
kernel.function("sys32_lstat64").call ?, |
| 48 |
kernel.function("sys_lstat64").call ?, |
| 49 |
%( arch == "s390" %? |
| 50 |
kernel.function("compat_sys_s390_lstat64").call ?, |
| 51 |
%) |
| 52 |
%( arch == "x86_64" %? |
| 53 |
kernel.function("compat_sys_x86_lstat64").call ?, |
| 54 |
%) |
| 55 |
kernel.function("sys_oabi_lstat64").call ? |
| 56 |
{ |
| 57 |
@_SYSCALL_LSTAT_NAME |
| 58 |
path = user_string_quoted(@__pointer($filename)) |
| 59 |
buf_uaddr = @__pointer($statbuf) |
| 60 |
@_SYSCALL_LSTAT_ARGSTR |
| 61 |
} |
| 62 |
probe dw_syscall.lstat.return = kernel.function("sys_lstat").return ?, |
| 63 |
kernel.function("sys_newlstat").return ?, |
| 64 |
kernel.function("compat_sys_newlstat").return ?, |
| 65 |
kernel.function("sys32_lstat64").return ?, |
| 66 |
kernel.function("sys_lstat64").return ?, |
| 67 |
%( arch == "s390" %? |
| 68 |
kernel.function("compat_sys_s390_lstat64").return ?, |
| 69 |
%) |
| 70 |
%( arch == "x86_64" %? |
| 71 |
kernel.function("compat_sys_x86_lstat64").return ?, |
| 72 |
%) |
| 73 |
kernel.function("sys_oabi_lstat64").return ? |
| 74 |
{ |
| 75 |
@_SYSCALL_LSTAT_NAME |
| 76 |
@SYSC_RETVALSTR($return) |
| 77 |
} |
| 78 |
|
| 79 |
# nd_lstat _____________________________________________________ |
| 80 |
|
| 81 |
probe nd_syscall.lstat = nd1_syscall.lstat!, nd2_syscall.lstat!, tp_syscall.lstat |
| 82 |
{ } |
| 83 |
|
| 84 |
probe nd1_syscall.lstat = kprobe.function("sys_lstat") ?, |
| 85 |
kprobe.function("sys_newlstat") ?, |
| 86 |
kprobe.function("compat_sys_newlstat") ?, |
| 87 |
kprobe.function("sys32_lstat64") ?, |
| 88 |
kprobe.function("sys_lstat64") ?, |
| 89 |
%( arch == "s390" %? |
| 90 |
kprobe.function("compat_sys_s390_lstat64") ?, |
| 91 |
%) |
| 92 |
%( arch == "x86_64" %? |
| 93 |
kprobe.function("compat_sys_x86_lstat64") ?, |
| 94 |
%) |
| 95 |
kprobe.function("sys_oabi_lstat64") ? |
| 96 |
{ |
| 97 |
@_SYSCALL_LSTAT_NAME |
| 98 |
asmlinkage() |
| 99 |
@_SYSCALL_LSTAT_REGARGS |
| 100 |
@_SYSCALL_LSTAT_ARGSTR |
| 101 |
} |
| 102 |
|
| 103 |
/* kernel 4.17+ */ |
| 104 |
probe nd2_syscall.lstat = |
| 105 |
kprobe.function(@arch_syscall_prefix "sys_lstat") ?, |
| 106 |
kprobe.function(@arch_syscall_prefix "sys_newlstat") ?, |
| 107 |
kprobe.function(@arch_syscall_prefix "compat_sys_newlstat") ?, |
| 108 |
kprobe.function(@arch_syscall_prefix "compat_sys_x86_lstat64") ? |
| 109 |
{ |
| 110 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 111 |
@_SYSCALL_LSTAT_NAME |
| 112 |
@_SYSCALL_LSTAT_REGARGS |
| 113 |
@_SYSCALL_LSTAT_ARGSTR |
| 114 |
}, |
| 115 |
{ |
| 116 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_LSTAT_REGARGS_STORE %) |
| 117 |
} |
| 118 |
|
| 119 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 120 |
probe tp_syscall.lstat = __tp_syscall.lstat, |
| 121 |
__tp_syscall.lstat64, |
| 122 |
__tp_syscall.newlstat |
| 123 |
{ |
| 124 |
__set_syscall_pt_regs($regs) |
| 125 |
@_SYSCALL_LSTAT_NAME |
| 126 |
@_SYSCALL_LSTAT_REGARGS |
| 127 |
@_SYSCALL_LSTAT_ARGSTR |
| 128 |
}, |
| 129 |
{ |
| 130 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_LSTAT_REGARGS_STORE %) |
| 131 |
} |
| 132 |
probe __tp_syscall.lstat = kernel.trace("sys_enter") |
| 133 |
{ |
| 134 |
@__syscall_compat_gate(@const("__NR_oldlstat"), @const("__NR_compat_oldlstat")) |
| 135 |
} |
| 136 |
probe __tp_syscall.lstat64 = kernel.trace("sys_enter") |
| 137 |
{ |
| 138 |
@__syscall_compat_gate(@const("__NR_lstat64"), @const("__NR_compat_lstat64")) |
| 139 |
} |
| 140 |
probe __tp_syscall.newlstat = kernel.trace("sys_enter") |
| 141 |
{ |
| 142 |
@__syscall_compat_gate(@const("__NR_lstat"), @const("__NR_compat_lstat")) |
| 143 |
} |
| 144 |
|
| 145 |
probe nd_syscall.lstat.return = nd1_syscall.lstat.return!, nd2_syscall.lstat.return!, tp_syscall.lstat.return |
| 146 |
{ } |
| 147 |
|
| 148 |
probe nd1_syscall.lstat.return = kprobe.function("sys_lstat").return ?, |
| 149 |
kprobe.function("sys_newlstat").return ?, |
| 150 |
kprobe.function("compat_sys_newlstat").return ?, |
| 151 |
kprobe.function("sys32_lstat64").return ?, |
| 152 |
kprobe.function("sys_lstat64").return ?, |
| 153 |
%( arch == "s390" %? |
| 154 |
kprobe.function("compat_sys_s390_lstat64").return ?, |
| 155 |
%) |
| 156 |
%( arch == "x86_64" %? |
| 157 |
kprobe.function("compat_sys_x86_lstat64").return ?, |
| 158 |
%) |
| 159 |
kprobe.function("sys_oabi_lstat64").return ? |
| 160 |
{ |
| 161 |
@_SYSCALL_LSTAT_NAME |
| 162 |
@SYSC_RETVALSTR(returnval()) |
| 163 |
} |
| 164 |
|
| 165 |
/* kernel 4.17+ */ |
| 166 |
probe nd2_syscall.lstat.return = |
| 167 |
kprobe.function(@arch_syscall_prefix "sys_lstat").return ?, |
| 168 |
kprobe.function(@arch_syscall_prefix "sys_newlstat").return ?, |
| 169 |
kprobe.function(@arch_syscall_prefix "compat_sys_newlstat").return ?, |
| 170 |
kprobe.function(@arch_syscall_prefix "compat_sys_x86_lstat64").return ? |
| 171 |
{ |
| 172 |
@_SYSCALL_LSTAT_NAME |
| 173 |
@SYSC_RETVALSTR(returnval()) |
| 174 |
} |
| 175 |
|
| 176 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 177 |
probe tp_syscall.lstat.return = __tp_syscall.lstat.return, |
| 178 |
__tp_syscall.lstat64.return, |
| 179 |
__tp_syscall.newlstat.return |
| 180 |
{ |
| 181 |
__set_syscall_pt_regs($regs) |
| 182 |
@_SYSCALL_LSTAT_NAME |
| 183 |
@SYSC_RETVALSTR($ret) |
| 184 |
} |
| 185 |
probe __tp_syscall.lstat.return = kernel.trace("sys_exit") |
| 186 |
{ |
| 187 |
@__syscall_compat_gate(@const("__NR_oldlstat"), @const("__NR_compat_oldlstat")) |
| 188 |
} |
| 189 |
probe __tp_syscall.lstat64.return = kernel.trace("sys_exit") |
| 190 |
{ |
| 191 |
@__syscall_compat_gate(@const("__NR_lstat64"), @const("__NR_compat_lstat64")) |
| 192 |
} |
| 193 |
probe __tp_syscall.newlstat.return = kernel.trace("sys_exit") |
| 194 |
{ |
| 195 |
@__syscall_compat_gate(@const("__NR_lstat"), @const("__NR_compat_lstat")) |
| 196 |
} |