Debian Codegraph @

tapset/linux/sysc_splice.stp

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