| 1 |
# vmsplice ___________________________________________________ |
| 2 |
# |
| 3 |
# long sys_vmsplice(int fd, const struct iovec __user *iov, |
| 4 |
# unsigned long nr_segs, unsigned int flags) |
| 5 |
# long compat_sys_vmsplice(int fd, const struct compat_iovec __user *iov32, |
| 6 |
# unsigned int nr_segs, unsigned int flags) |
| 7 |
# |
| 8 |
|
| 9 |
@define _SYSCALL_VMSPLICE_NAME |
| 10 |
%( |
| 11 |
name = "vmsplice" |
| 12 |
%) |
| 13 |
|
| 14 |
@define _SYSCALL_VMSPLICE_ARGSTR |
| 15 |
%( |
| 16 |
argstr = sprintf("%d, %p, %u, %s", fd, iov, nr_segs, flags_str) |
| 17 |
%) |
| 18 |
|
| 19 |
@define _SYSCALL_VMSPLICE_REGARGS |
| 20 |
%( |
| 21 |
fd = int_arg(1) |
| 22 |
iov = pointer_arg(2) |
| 23 |
nr_segs = ulong_arg(3) |
| 24 |
flags = uint_arg(4) |
| 25 |
flags_str = _stp_splice_flags_str(flags) |
| 26 |
%) |
| 27 |
|
| 28 |
@define _SYSCALL_VMSPLICE_REGARGS_STORE |
| 29 |
%( |
| 30 |
if (@probewrite(fd)) |
| 31 |
set_int_arg(1, fd) |
| 32 |
|
| 33 |
if (@probewrite(iov)) |
| 34 |
set_pointer_arg(2, iov) |
| 35 |
|
| 36 |
if (@probewrite(nr_segs)) |
| 37 |
set_ulong_arg(3, nr_segs) |
| 38 |
|
| 39 |
if (@probewrite(flags)) |
| 40 |
set_uint_arg(4, flags) |
| 41 |
%) |
| 42 |
|
| 43 |
probe syscall.vmsplice = dw_syscall.vmsplice !, nd_syscall.vmsplice ? {} |
| 44 |
probe syscall.vmsplice.return = dw_syscall.vmsplice.return !, |
| 45 |
nd_syscall.vmsplice.return ? {} |
| 46 |
|
| 47 |
# dw_vmsplice _____________________________________________________ |
| 48 |
|
| 49 |
probe dw_syscall.vmsplice = kernel.function("sys_vmsplice").call ? |
| 50 |
{ |
| 51 |
@__syscall_gate_compat_simple |
| 52 |
@_SYSCALL_VMSPLICE_NAME |
| 53 |
fd = __int32($fd) |
| 54 |
/* Kernel commit 87a3002af9e30 changed $iov to $uiov */ |
| 55 |
iov = @choose_defined($uiov, $iov) |
| 56 |
nr_segs = __ulong($nr_segs) |
| 57 |
flags = $flags |
| 58 |
flags_str = _stp_splice_flags_str(flags) |
| 59 |
@_SYSCALL_VMSPLICE_ARGSTR |
| 60 |
} |
| 61 |
probe dw_syscall.vmsplice.return = kernel.function("sys_vmsplice").return ? |
| 62 |
{ |
| 63 |
@__syscall_gate_compat_simple |
| 64 |
@_SYSCALL_VMSPLICE_NAME |
| 65 |
@SYSC_RETVALSTR($return) |
| 66 |
} |
| 67 |
|
| 68 |
# nd_vmsplice _____________________________________________________ |
| 69 |
|
| 70 |
probe nd_syscall.vmsplice = nd1_syscall.vmsplice!, nd2_syscall.vmsplice!, tp_syscall.vmsplice |
| 71 |
{ } |
| 72 |
|
| 73 |
probe nd1_syscall.vmsplice = kprobe.function("sys_vmsplice") ? |
| 74 |
{ |
| 75 |
@__syscall_gate_compat_simple |
| 76 |
@_SYSCALL_VMSPLICE_NAME |
| 77 |
asmlinkage() |
| 78 |
@_SYSCALL_VMSPLICE_REGARGS |
| 79 |
@_SYSCALL_VMSPLICE_ARGSTR |
| 80 |
} |
| 81 |
|
| 82 |
/* kernel 4.17+ */ |
| 83 |
probe nd2_syscall.vmsplice = kprobe.function(@arch_syscall_prefix "sys_vmsplice") ? |
| 84 |
{ |
| 85 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 86 |
@_SYSCALL_VMSPLICE_NAME |
| 87 |
@_SYSCALL_VMSPLICE_REGARGS |
| 88 |
@_SYSCALL_VMSPLICE_ARGSTR |
| 89 |
}, |
| 90 |
{ |
| 91 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_VMSPLICE_REGARGS_STORE %) |
| 92 |
} |
| 93 |
|
| 94 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 95 |
probe tp_syscall.vmsplice = kernel.trace("sys_enter") |
| 96 |
{ |
| 97 |
__set_syscall_pt_regs($regs) |
| 98 |
@__syscall_gate(@const("__NR_vmsplice")) |
| 99 |
@_SYSCALL_VMSPLICE_NAME |
| 100 |
@_SYSCALL_VMSPLICE_REGARGS |
| 101 |
@_SYSCALL_VMSPLICE_ARGSTR |
| 102 |
}, |
| 103 |
{ |
| 104 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_VMSPLICE_REGARGS_STORE %) |
| 105 |
} |
| 106 |
|
| 107 |
probe nd_syscall.vmsplice.return = nd1_syscall.vmsplice.return!, nd2_syscall.vmsplice.return!, tp_syscall.vmsplice.return |
| 108 |
{ } |
| 109 |
|
| 110 |
probe nd1_syscall.vmsplice.return = kprobe.function("sys_vmsplice").return ? |
| 111 |
{ |
| 112 |
@__syscall_gate_compat_simple |
| 113 |
@_SYSCALL_VMSPLICE_NAME |
| 114 |
@SYSC_RETVALSTR(returnval()) |
| 115 |
} |
| 116 |
|
| 117 |
/* kernel 4.17+ */ |
| 118 |
probe nd2_syscall.vmsplice.return = kprobe.function(@arch_syscall_prefix "sys_vmsplice").return ? |
| 119 |
{ |
| 120 |
@_SYSCALL_VMSPLICE_NAME |
| 121 |
@SYSC_RETVALSTR(returnval()) |
| 122 |
} |
| 123 |
|
| 124 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 125 |
probe tp_syscall.vmsplice.return = kernel.trace("sys_exit") |
| 126 |
{ |
| 127 |
__set_syscall_pt_regs($regs) |
| 128 |
@__syscall_gate(@const("__NR_vmsplice")) |
| 129 |
@_SYSCALL_VMSPLICE_NAME |
| 130 |
@SYSC_RETVALSTR($ret) |
| 131 |
} |
| 132 |
|
| 133 |
# compat_vmsplice ____________________________________________ |
| 134 |
# |
| 135 |
# long sys_vmsplice(int fd, const struct iovec __user *iov, |
| 136 |
# unsigned long nr_segs, unsigned int flags) |
| 137 |
# long compat_sys_vmsplice(int fd, const struct compat_iovec __user *iov32, |
| 138 |
# unsigned int nr_segs, unsigned int flags) |
| 139 |
# |
| 140 |
|
| 141 |
probe syscall.compat_vmsplice = dw_syscall.compat_vmsplice !, |
| 142 |
nd_syscall.compat_vmsplice ? {} |
| 143 |
probe syscall.compat_vmsplice.return = dw_syscall.compat_vmsplice.return !, |
| 144 |
nd_syscall.compat_vmsplice.return ? {} |
| 145 |
|
| 146 |
# dw_compat_vmsplice _____________________________________________________ |
| 147 |
|
| 148 |
probe dw_syscall.compat_vmsplice = kernel.function("compat_sys_vmsplice").call ? |
| 149 |
{ |
| 150 |
@_SYSCALL_VMSPLICE_NAME |
| 151 |
fd = __int32($fd) |
| 152 |
iov = @__pointer($iov32) |
| 153 |
nr_segs = __uint32($nr_segs) |
| 154 |
flags = $flags |
| 155 |
flags_str = _stp_splice_flags_str(flags) |
| 156 |
@_SYSCALL_VMSPLICE_ARGSTR |
| 157 |
} |
| 158 |
probe dw_syscall.compat_vmsplice.return = kernel.function("compat_sys_vmsplice").return ? |
| 159 |
{ |
| 160 |
@_SYSCALL_VMSPLICE_NAME |
| 161 |
@SYSC_RETVALSTR($return) |
| 162 |
} |
| 163 |
|
| 164 |
# nd_compat_vmsplice _____________________________________________________ |
| 165 |
|
| 166 |
probe nd_syscall.compat_vmsplice = nd1_syscall.compat_vmsplice!, nd2_syscall.compat_vmsplice!, tp_syscall.compat_vmsplice |
| 167 |
{ } |
| 168 |
|
| 169 |
probe nd1_syscall.compat_vmsplice = kprobe.function("compat_sys_vmsplice") ? |
| 170 |
{ |
| 171 |
@_SYSCALL_VMSPLICE_NAME |
| 172 |
asmlinkage() |
| 173 |
@_SYSCALL_VMSPLICE_REGARGS |
| 174 |
@_SYSCALL_VMSPLICE_ARGSTR |
| 175 |
} |
| 176 |
|
| 177 |
/* kernel 4.17+ */ |
| 178 |
probe nd2_syscall.compat_vmsplice = |
| 179 |
kprobe.function(@arch_syscall_prefix "compat_sys_vmsplice") ? |
| 180 |
{ |
| 181 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 182 |
@_SYSCALL_VMSPLICE_NAME |
| 183 |
@_SYSCALL_VMSPLICE_REGARGS |
| 184 |
@_SYSCALL_VMSPLICE_ARGSTR |
| 185 |
}, |
| 186 |
{ |
| 187 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_VMSPLICE_REGARGS_STORE %) |
| 188 |
} |
| 189 |
|
| 190 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 191 |
probe tp_syscall.compat_vmsplice = kernel.trace("sys_enter") |
| 192 |
{ |
| 193 |
__set_syscall_pt_regs($regs) |
| 194 |
@__compat_syscall_gate(@const("__NR_compat_vmsplice")) |
| 195 |
@_SYSCALL_VMSPLICE_NAME |
| 196 |
@_SYSCALL_VMSPLICE_REGARGS |
| 197 |
@_SYSCALL_VMSPLICE_ARGSTR |
| 198 |
}, |
| 199 |
{ |
| 200 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_VMSPLICE_REGARGS_STORE %) |
| 201 |
} |
| 202 |
|
| 203 |
probe nd_syscall.compat_vmsplice.return = nd1_syscall.compat_vmsplice.return!, nd2_syscall.compat_vmsplice.return!, tp_syscall.compat_vmsplice.return |
| 204 |
{ } |
| 205 |
|
| 206 |
probe nd1_syscall.compat_vmsplice.return = kprobe.function("compat_sys_vmsplice").return ? |
| 207 |
{ |
| 208 |
@_SYSCALL_VMSPLICE_NAME |
| 209 |
@SYSC_RETVALSTR(returnval()) |
| 210 |
} |
| 211 |
|
| 212 |
/* kernel 4.17+ */ |
| 213 |
probe nd2_syscall.compat_vmsplice.return = |
| 214 |
kprobe.function(@arch_syscall_prefix "compat_sys_vmsplice").return ? |
| 215 |
{ |
| 216 |
@_SYSCALL_VMSPLICE_NAME |
| 217 |
@SYSC_RETVALSTR(returnval()) |
| 218 |
} |
| 219 |
|
| 220 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 221 |
probe tp_syscall.compat_vmsplice.return = kernel.trace("sys_exit") |
| 222 |
{ |
| 223 |
__set_syscall_pt_regs($regs) |
| 224 |
@__compat_syscall_gate(@const("__NR_compat_vmsplice")) |
| 225 |
@_SYSCALL_VMSPLICE_NAME |
| 226 |
@SYSC_RETVALSTR($ret) |
| 227 |
} |