| 1 |
# copy_file_range ___________________________________________ |
| 2 |
# SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, |
| 3 |
# int, fd_out, loff_t __user *, off_out, |
| 4 |
# size_t, len, unsigned int, flags) |
| 5 |
|
| 6 |
@define _SYSCALL_COPY_FILE_RANGE_NAME |
| 7 |
%( |
| 8 |
name = "copy_file_range" |
| 9 |
%) |
| 10 |
|
| 11 |
@define _SYSCALL_COPY_FILE_RANGE_ARGSTR |
| 12 |
%( |
| 13 |
argstr = sprintf("%d, %p, %d, %p, %u, 0x%x", fd_in, off_in, fd_out, |
| 14 |
off_out, len, flags) |
| 15 |
%) |
| 16 |
|
| 17 |
@define _SYSCALL_COPY_FILE_RANGE_REGARGS |
| 18 |
%( |
| 19 |
fd_in = int_arg(1) |
| 20 |
off_in = pointer_arg(2) |
| 21 |
fd_out = int_arg(3) |
| 22 |
off_out = pointer_arg(4) |
| 23 |
len = ulong_arg(5) |
| 24 |
flags = uint_arg(6) |
| 25 |
%) |
| 26 |
|
| 27 |
@define _SYSCALL_COPY_FILE_RANGE_REGARGS_STORE |
| 28 |
%( |
| 29 |
if (@probewrite(fd_in)) |
| 30 |
set_int_arg(1, fd_in) |
| 31 |
|
| 32 |
if (@probewrite(off_in)) |
| 33 |
set_pointer_arg(2, off_in) |
| 34 |
|
| 35 |
if (@probewrite(fd_out)) |
| 36 |
set_int_arg(3, fd_out) |
| 37 |
|
| 38 |
if (@probewrite(off_out)) |
| 39 |
set_pointer_arg(4, off_out) |
| 40 |
|
| 41 |
if (@probewrite(len)) |
| 42 |
set_ulong_arg(5, len) |
| 43 |
|
| 44 |
if (@probewrite(flags)) |
| 45 |
set_uint_arg(6, flags) |
| 46 |
%) |
| 47 |
|
| 48 |
probe syscall.copy_file_range = dw_syscall.copy_file_range !, nd_syscall.copy_file_range ? {} |
| 49 |
probe syscall.copy_file_range.return = dw_syscall.copy_file_range.return !, nd_syscall.copy_file_range.return ? {} |
| 50 |
|
| 51 |
# dw_copy_file_range _____________________________________________________ |
| 52 |
|
| 53 |
probe dw_syscall.copy_file_range = kernel.function("sys_copy_file_range").call ? |
| 54 |
{ |
| 55 |
@_SYSCALL_COPY_FILE_RANGE_NAME |
| 56 |
fd_in = __int32($fd_in) |
| 57 |
off_in = @__pointer($off_in) |
| 58 |
fd_out = __int32($fd_out) |
| 59 |
off_out = @__pointer($off_out) |
| 60 |
len = __ulong($len) |
| 61 |
flags = __uint32($flags) |
| 62 |
@_SYSCALL_COPY_FILE_RANGE_ARGSTR |
| 63 |
} |
| 64 |
probe dw_syscall.copy_file_range.return = |
| 65 |
kernel.function("sys_copy_file_range").return ? |
| 66 |
{ |
| 67 |
@_SYSCALL_COPY_FILE_RANGE_NAME |
| 68 |
@SYSC_RETVALSTR($return) |
| 69 |
} |
| 70 |
|
| 71 |
# nd_copy_file_range _____________________________________________________ |
| 72 |
|
| 73 |
probe nd_syscall.copy_file_range = nd1_syscall.copy_file_range!, nd2_syscall.copy_file_range!, tp_syscall.copy_file_range |
| 74 |
{ } |
| 75 |
|
| 76 |
probe nd1_syscall.copy_file_range = |
| 77 |
kprobe.function("sys_copy_file_range").call ? |
| 78 |
{ |
| 79 |
@_SYSCALL_COPY_FILE_RANGE_NAME |
| 80 |
@_SYSCALL_COPY_FILE_RANGE_REGARGS |
| 81 |
@_SYSCALL_COPY_FILE_RANGE_ARGSTR |
| 82 |
} |
| 83 |
|
| 84 |
/* kernel 4.17+ */ |
| 85 |
probe nd2_syscall.copy_file_range = kprobe.function(@arch_syscall_prefix "sys_copy_file_range") ? |
| 86 |
{ |
| 87 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 88 |
@_SYSCALL_COPY_FILE_RANGE_NAME |
| 89 |
@_SYSCALL_COPY_FILE_RANGE_REGARGS |
| 90 |
@_SYSCALL_COPY_FILE_RANGE_ARGSTR |
| 91 |
}, |
| 92 |
{ |
| 93 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_COPY_FILE_RANGE_REGARGS_STORE %) |
| 94 |
} |
| 95 |
|
| 96 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 97 |
probe tp_syscall.copy_file_range = kernel.trace("sys_enter") |
| 98 |
{ |
| 99 |
__set_syscall_pt_regs($regs) |
| 100 |
@__syscall_compat_gate(@const("__NR_copy_file_range"), @const("__NR_compat_copy_file_range")) |
| 101 |
@_SYSCALL_COPY_FILE_RANGE_NAME |
| 102 |
@_SYSCALL_COPY_FILE_RANGE_REGARGS |
| 103 |
@_SYSCALL_COPY_FILE_RANGE_ARGSTR |
| 104 |
}, |
| 105 |
{ |
| 106 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_COPY_FILE_RANGE_REGARGS_STORE %) |
| 107 |
} |
| 108 |
|
| 109 |
probe nd_syscall.copy_file_range.return = nd1_syscall.copy_file_range.return!, nd2_syscall.copy_file_range.return!, tp_syscall.copy_file_range.return |
| 110 |
{ } |
| 111 |
|
| 112 |
probe nd1_syscall.copy_file_range.return = |
| 113 |
kprobe.function("sys_copy_file_range").return ? |
| 114 |
{ |
| 115 |
@_SYSCALL_COPY_FILE_RANGE_NAME |
| 116 |
@SYSC_RETVALSTR(returnval()) |
| 117 |
} |
| 118 |
|
| 119 |
/* kernel 4.17+ */ |
| 120 |
probe nd2_syscall.copy_file_range.return = kprobe.function(@arch_syscall_prefix "sys_copy_file_range").return ? |
| 121 |
{ |
| 122 |
@_SYSCALL_COPY_FILE_RANGE_NAME |
| 123 |
@SYSC_RETVALSTR(returnval()) |
| 124 |
} |
| 125 |
|
| 126 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 127 |
probe tp_syscall.copy_file_range.return = kernel.trace("sys_exit") |
| 128 |
{ |
| 129 |
__set_syscall_pt_regs($regs) |
| 130 |
@__syscall_compat_gate(@const("__NR_copy_file_range"), @const("__NR_compat_copy_file_range")) |
| 131 |
@_SYSCALL_COPY_FILE_RANGE_NAME |
| 132 |
@SYSC_RETVALSTR($ret) |
| 133 |
} |