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
|
# sendfile ___________________________________________________
#
# ssize_t sys_sendfile[64](int out_fd,
# int in_fd,
# off_t __user *offset,
# size_t count)
# SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd, loff_t __user *, offset,
# size_t, count)
# COMPAT_SYSCALL_DEFINE4(sendfile, int, out_fd, int, in_fd,
# compat_off_t __user *, offset, compat_size_t, count)
# COMPAT_SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd,
# compat_loff_t __user *, offset, compat_size_t, count)
#
@define _SYSCALL_SENDFILE_NAME
%(
name = "sendfile"
%)
@define _SYSCALL_SENDFILE_ARGSTR
%(
argstr = sprintf("%d, %d, %p, %u", out_fd, in_fd, offset_uaddr, count)
%)
@define _SYSCALL_SENDFILE_REGARGS
%(
out_fd = int_arg(1)
in_fd = int_arg(2)
offset_uaddr = pointer_arg(3)
count = ulong_arg(4)
%)
@define _SYSCALL_SENDFILE_REGARGS_STORE
%(
if (@probewrite(out_fd))
set_int_arg(1, out_fd)
if (@probewrite(in_fd))
set_int_arg(2, in_fd)
if (@probewrite(offset_uaddr))
set_pointer_arg(3, offset_uaddr)
if (@probewrite(count))
set_ulong_arg(4, count)
%)
probe syscall.sendfile = dw_syscall.sendfile !, nd_syscall.sendfile ? {}
probe syscall.sendfile.return = dw_syscall.sendfile.return !,
nd_syscall.sendfile.return ? {}
# dw_sendfile _____________________________________________________
probe dw_syscall.sendfile = __syscall.sendfile ?,
kernel.function("compat_sys_sendfile").call ?,
kernel.function("compat_sys_sendfile64").call ?,
kernel.function("sys32_sendfile").call ?
{
@_SYSCALL_SENDFILE_NAME
out_fd = __int32($out_fd)
in_fd = __int32($in_fd)
offset_uaddr = $offset
count = @__compat_ulong($count)
@_SYSCALL_SENDFILE_ARGSTR
}
probe __syscall.sendfile = kernel.function("sys_sendfile").call ?,
kernel.function("sys_sendfile64").call ?
{
@__syscall_gate2(@const("__NR_sendfile"), @const("__NR_sendfile64"))
}
probe dw_syscall.sendfile.return = __syscall.sendfile.return ?,
kernel.function("compat_sys_sendfile").return ?,
kernel.function("compat_sys_sendfile64").return ?,
kernel.function("sys32_sendfile").return ?
{
@_SYSCALL_SENDFILE_NAME
@SYSC_RETVALSTR($return)
}
probe __syscall.sendfile.return = kernel.function("sys_sendfile").return ?,
kernel.function("sys_sendfile64").return ?
{
@__syscall_gate2(@const("__NR_sendfile"), @const("__NR_sendfile64"))
}
# nd_sendfile _____________________________________________________
probe nd_syscall.sendfile = nd1_syscall.sendfile!, nd2_syscall.sendfile!, tp_syscall.sendfile
{ }
probe nd1_syscall.sendfile = __nd1_syscall.sendfile ?,
kprobe.function("compat_sys_sendfile").call ?,
kprobe.function("compat_sys_sendfile64").call ?,
kprobe.function("sys32_sendfile").call ?
{
@_SYSCALL_SENDFILE_NAME
asmlinkage()
@_SYSCALL_SENDFILE_REGARGS
@_SYSCALL_SENDFILE_ARGSTR
}
probe __nd1_syscall.sendfile = kprobe.function("sys_sendfile").call ?,
kprobe.function("sys_sendfile64").call ?
{
@__syscall_gate2(@const("__NR_sendfile"), @const("__NR_sendfile64"))
}
/* kernel 4.17+ */
probe nd2_syscall.sendfile =
kprobe.function(@arch_syscall_prefix "sys_sendfile64") ?,
kprobe.function(@arch_syscall_prefix "compat_sys_sendfile") ?
{
__set_syscall_pt_regs(pointer_arg(1))
@_SYSCALL_SENDFILE_NAME
@_SYSCALL_SENDFILE_REGARGS
@_SYSCALL_SENDFILE_ARGSTR
},
{
%( @_IS_SREG_KERNEL %? @_SYSCALL_SENDFILE_REGARGS_STORE %)
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.sendfile = kernel.trace("sys_enter")
{
__set_syscall_pt_regs($regs)
@__syscall_compat_gate(@const("__NR_sendfile"), @const("__NR_compat_sendfile"))
@_SYSCALL_SENDFILE_NAME
@_SYSCALL_SENDFILE_REGARGS
@_SYSCALL_SENDFILE_ARGSTR
},
{
%( @_IS_SREG_KERNEL %? @_SYSCALL_SENDFILE_REGARGS_STORE %)
}
probe nd_syscall.sendfile.return = nd1_syscall.sendfile.return!, nd2_syscall.sendfile.return!, tp_syscall.sendfile.return
{ }
probe nd1_syscall.sendfile.return = __nd1_syscall.sendfile.return ?,
kprobe.function("compat_sys_sendfile").return ?,
kprobe.function("compat_sys_sendfile64").return ?,
kprobe.function("sys32_sendfile").return ?
{
@_SYSCALL_SENDFILE_NAME
@SYSC_RETVALSTR(returnval())
}
probe __nd1_syscall.sendfile.return = kprobe.function("sys_sendfile").return ?,
kprobe.function("sys_sendfile64").return ?
{
@__syscall_gate2(@const("__NR_sendfile"), @const("__NR_sendfile64"))
}
/* kernel 4.17+ */
probe nd2_syscall.sendfile.return =
kprobe.function(@arch_syscall_prefix "sys_sendfile64").return ?,
kprobe.function(@arch_syscall_prefix "compat_sys_sendfile").return ?
{
@_SYSCALL_SENDFILE_NAME
@SYSC_RETVALSTR(returnval())
}
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.sendfile.return = kernel.trace("sys_exit")
{
__set_syscall_pt_regs($regs)
@__syscall_compat_gate(@const("__NR_sendfile"), @const("__NR_compat_sendfile"))
@_SYSCALL_SENDFILE_NAME
@SYSC_RETVALSTR($ret)
}
|