1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
# pwrite64 ___________________________________________________
#
# ssize_t sys_pwrite64(unsigned int fd,
# const char __user *buf,
# size_t count,
# loff_t pos)
#
@define _SYSCALL_PWRITE_NAME
%(
name = "pwrite"
%)
@define _SYSCALL_PWRITE_ARGSTR
%(
argstr = sprintf("%d, %s, %u, %d", fd, buf_str, count, offset)
%)
@define _SYSCALL_PWRITE_REGARGS
%(
fd = int_arg(1)
buf_uaddr = pointer_arg(2)
count = ulong_arg(3)
buf_str = user_buffer_quoted(buf_uaddr, count, syscall_string_trunc)
%)
@define _SYSCALL_PWRITE_REGARGS_STORE
%(
if (@probewrite(fd))
set_int_arg(1, fd)
if (@probewrite(buf_uaddr))
set_pointer_arg(2, buf_uaddr)
if (@probewrite(count))
set_ulong_arg(3, count)
%)
probe syscall.pwrite = dw_syscall.pwrite !, nd_syscall.pwrite ? {}
probe syscall.pwrite.return = dw_syscall.pwrite.return !,
nd_syscall.pwrite.return ? {}
# dw_pwrite _____________________________________________________
probe dw_syscall.pwrite = kernel.function("sys_pwrite64").call
{
%( arch == "s390" || arch == "x86_64" %?
@__syscall_gate(@const("__NR_pwrite64"))
%)
@_SYSCALL_PWRITE_NAME
fd = __int32($fd)
buf_uaddr = $buf
count = @__compat_ulong($count)
buf_str = user_buffer_quoted(buf_uaddr, count, syscall_string_trunc)
offset = $pos
@_SYSCALL_PWRITE_ARGSTR
}
probe dw_syscall.pwrite.return = kernel.function("sys_pwrite64").return
{
%( arch == "s390" || arch == "x86_64" %?
@__syscall_gate(@const("__NR_pwrite64"))
%)
@_SYSCALL_PWRITE_NAME
@SYSC_RETVALSTR($return)
}
# nd_pwrite _____________________________________________________
probe nd_syscall.pwrite = nd1_syscall.pwrite!, nd2_syscall.pwrite!, tp_syscall.pwrite
{ }
probe nd1_syscall.pwrite = kprobe.function("sys_pwrite64") ?
{
%( arch == "s390" || arch == "x86_64" %?
@__syscall_gate(@const("__NR_pwrite64"))
%)
@_SYSCALL_PWRITE_NAME
asmlinkage()
@_SYSCALL_PWRITE_REGARGS
offset = longlong_arg(4)
@_SYSCALL_PWRITE_ARGSTR
}
/* kernel 4.17+ */
probe nd2_syscall.pwrite = kprobe.function(@arch_syscall_prefix "sys_pwrite64") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_PWRITE_NAME
@_SYSCALL_PWRITE_REGARGS
offset = longlong_arg(4)
@_SYSCALL_PWRITE_ARGSTR
},
{
%( @_IS_SREG_KERNEL %?
@_SYSCALL_PWRITE_REGARGS_STORE
if (@probewrite(offset))
set_longlong_arg(4, offset)
%)
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.pwrite = kernel.trace("sys_enter")
{
__set_syscall_pt_regs($regs)
@__syscall_gate(@const("__NR_pwrite64"))
@_SYSCALL_PWRITE_NAME
@_SYSCALL_PWRITE_REGARGS
offset = longlong_arg(4)
@_SYSCALL_PWRITE_ARGSTR
},
{
%( @_IS_SREG_KERNEL %?
@_SYSCALL_PWRITE_REGARGS_STORE
if (@probewrite(offset))
set_longlong_arg(4, offset)
%)
}
probe nd_syscall.pwrite.return = nd1_syscall.pwrite.return!, nd2_syscall.pwrite.return!, tp_syscall.pwrite.return
{ }
probe nd1_syscall.pwrite.return = kprobe.function("sys_pwrite64").return ?
{
%( arch == "s390" || arch == "x86_64" %?
@__syscall_gate(@const("__NR_pwrite64"))
%)
@_SYSCALL_PWRITE_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 4.17+ */
probe nd2_syscall.pwrite.return = kprobe.function(@arch_syscall_prefix "sys_pwrite64").return ?
{
@_SYSCALL_PWRITE_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.pwrite.return = kernel.trace("sys_exit")
{
__set_syscall_pt_regs($regs)
@__syscall_gate(@const("__NR_pwrite64"))
@_SYSCALL_PWRITE_NAME
@SYSC_RETVALSTR($ret)
}
# long sys32_pwrite64(unsigned int fd, const char __user *ubuf,
# size_t count, u32 poshi, u32 poslo)
# COMPAT_SYSCALL_DEFINE5(s390_pwrite64, unsigned int, fd,
# const char __user *, ubuf,
# compat_size_t, count, u32, high, u32, low)
probe syscall.pwrite32 = dw_syscall.pwrite32 !, nd_syscall.pwrite32 ? {}
probe syscall.pwrite32.return = dw_syscall.pwrite32.return !,
nd_syscall.pwrite32.return ? {}
# dw_pwrite32 _____________________________________________________
probe dw_syscall.pwrite32 =
%( arch == "s390" %?
kernel.function("compat_sys_s390_pwrite64").call ?,
%)
%( arch == "x86_64" %?
kernel.function("compat_sys_x86_pwrite64").call ?,
%)
kernel.function("sys32_pwrite64").call ?
{
@_SYSCALL_PWRITE_NAME
fd = __int32($fd)
count = @__compat_ulong($count)
offset = ((@choose_defined($poshi, $high) << 32)
+ __uint32(@choose_defined($poslo, $low)))
buf_uaddr = @__pointer(@choose_defined($buf, $ubuf))
buf_str = user_buffer_quoted(buf_uaddr, count, syscall_string_trunc)
@_SYSCALL_PWRITE_ARGSTR
}
probe dw_syscall.pwrite32.return =
%( arch == "s390" %?
kernel.function("compat_sys_s390_pwrite64").return ?,
%)
%( arch == "x86_64" %?
kernel.function("compat_sys_x86_pwrite64").return ?,
%)
kernel.function("sys32_pwrite64").return ?
{
@_SYSCALL_PWRITE_NAME
@SYSC_RETVALSTR($return)
}
# nd_pwrite32 _____________________________________________________
probe nd_syscall.pwrite32 = nd1_syscall.pwrite32!, nd2_syscall.pwrite32!, tp_syscall.pwrite32
{ }
probe nd1_syscall.pwrite32 =
%( arch == "s390" %?
kprobe.function("compat_sys_s390_pwrite64") ?,
%)
%( arch == "x86_64" %?
kprobe.function("compat_sys_x86_pwrite64") ?,
%)
kprobe.function("sys32_pwrite64") ?
{
@_SYSCALL_PWRITE_NAME
asmlinkage()
@_SYSCALL_PWRITE_REGARGS
offset = (u32_arg(4) << 32) + u32_arg(5)
@_SYSCALL_PWRITE_ARGSTR
}
/* kernel 4.17+ */
probe nd2_syscall.pwrite32 = kprobe.function(@arch_syscall_prefix "compat_sys_x86_pwrite") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_PWRITE_NAME
@_SYSCALL_PWRITE_REGARGS
offset = (u32_arg(5) << 32) + u32_arg(4)
@_SYSCALL_PWRITE_ARGSTR
},
{
%( @_IS_SREG_KERNEL %?
@_SYSCALL_PWRITE_REGARGS_STORE
if (@probewrite(offset)) {
set_u32_arg(4, offset & 0xffffffff)
set_u32_arg(5, offset >> 32)
}
%)
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.pwrite32 = kernel.trace("sys_enter")
{
__set_syscall_pt_regs($regs)
@__compat_syscall_gate(@const("__NR_compat_pwrite64"))
@_SYSCALL_PWRITE_NAME
@_SYSCALL_PWRITE_REGARGS
offset = (u32_arg(5) << 32) + u32_arg(4)
@_SYSCALL_PWRITE_ARGSTR
},
{
%( @_IS_SREG_KERNEL %?
@_SYSCALL_PWRITE_REGARGS_STORE
if (@probewrite(offset)) {
set_u32_arg(4, offset & 0xffffffff)
set_u32_arg(5, offset >> 32)
}
%)
}
probe nd_syscall.pwrite32.return = nd1_syscall.pwrite32.return!, nd2_syscall.pwrite32.return!, tp_syscall.pwrite32.return
{ }
probe nd1_syscall.pwrite32.return =
%( arch == "s390" %?
kprobe.function("compat_sys_s390_pwrite64").return ?,
%)
%( arch == "x86_64" %?
kprobe.function("compat_sys_x86_pwrite64").return ?,
%)
kprobe.function("sys32_pwrite64").return ?
{
@_SYSCALL_PWRITE_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 4.17+ */
probe nd2_syscall.pwrite32.return =
kprobe.function(@arch_syscall_prefix "compat_sys_x86_pwrite").return ?
{
@_SYSCALL_PWRITE_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.pwrite32.return = kernel.trace("sys_exit")
{
__set_syscall_pt_regs($regs)
@__compat_syscall_gate(@const("__NR_compat_pwrite64"))
@_SYSCALL_PWRITE_NAME
@SYSC_RETVALSTR($ret)
}
|