Debian Codegraph @

tapset/linux/sysc_sendfile.stp

raw
1 # sendfile ___________________________________________________
2 #
3 # ssize_t sys_sendfile[64](int out_fd,
4 # int in_fd,
5 # off_t __user *offset,
6 # size_t count)
7 # SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd, loff_t __user *, offset,
8 # size_t, count)
9 # COMPAT_SYSCALL_DEFINE4(sendfile, int, out_fd, int, in_fd,
10 # compat_off_t __user *, offset, compat_size_t, count)
11 # COMPAT_SYSCALL_DEFINE4(sendfile64, int, out_fd, int, in_fd,
12 # compat_loff_t __user *, offset, compat_size_t, count)
13 #
14
15 @define _SYSCALL_SENDFILE_NAME
16 %(
17 name = "sendfile"
18 %)
19
20 @define _SYSCALL_SENDFILE_ARGSTR
21 %(
22 argstr = sprintf("%d, %d, %p, %u", out_fd, in_fd, offset_uaddr, count)
23 %)
24
25 @define _SYSCALL_SENDFILE_REGARGS
26 %(
27 out_fd = int_arg(1)
28 in_fd = int_arg(2)
29 offset_uaddr = pointer_arg(3)
30 count = ulong_arg(4)
31 %)
32
33 @define _SYSCALL_SENDFILE_REGARGS_STORE
34 %(
35 if (@probewrite(out_fd))
36 set_int_arg(1, out_fd)
37
38 if (@probewrite(in_fd))
39 set_int_arg(2, in_fd)
40
41 if (@probewrite(offset_uaddr))
42 set_pointer_arg(3, offset_uaddr)
43
44 if (@probewrite(count))
45 set_ulong_arg(4, count)
46 %)
47
48 probe syscall.sendfile = dw_syscall.sendfile !, nd_syscall.sendfile ? {}
49 probe syscall.sendfile.return = dw_syscall.sendfile.return !,
50 nd_syscall.sendfile.return ? {}
51
52 # dw_sendfile _____________________________________________________
53
54 probe dw_syscall.sendfile = __syscall.sendfile ?,
55 kernel.function("compat_sys_sendfile").call ?,
56 kernel.function("compat_sys_sendfile64").call ?,
57 kernel.function("sys32_sendfile").call ?
58 {
59 @_SYSCALL_SENDFILE_NAME
60 out_fd = __int32($out_fd)
61 in_fd = __int32($in_fd)
62 offset_uaddr = $offset
63 count = @__compat_ulong($count)
64 @_SYSCALL_SENDFILE_ARGSTR
65 }
66 probe __syscall.sendfile = kernel.function("sys_sendfile").call ?,
67 kernel.function("sys_sendfile64").call ?
68 {
69 @__syscall_gate2(@const("__NR_sendfile"), @const("__NR_sendfile64"))
70 }
71 probe dw_syscall.sendfile.return = __syscall.sendfile.return ?,
72 kernel.function("compat_sys_sendfile").return ?,
73 kernel.function("compat_sys_sendfile64").return ?,
74 kernel.function("sys32_sendfile").return ?
75 {
76 @_SYSCALL_SENDFILE_NAME
77 @SYSC_RETVALSTR($return)
78 }
79 probe __syscall.sendfile.return = kernel.function("sys_sendfile").return ?,
80 kernel.function("sys_sendfile64").return ?
81 {
82 @__syscall_gate2(@const("__NR_sendfile"), @const("__NR_sendfile64"))
83 }
84
85 # nd_sendfile _____________________________________________________
86
87 probe nd_syscall.sendfile = nd1_syscall.sendfile!, nd2_syscall.sendfile!, tp_syscall.sendfile
88 { }
89
90 probe nd1_syscall.sendfile = __nd1_syscall.sendfile ?,
91 kprobe.function("compat_sys_sendfile").call ?,
92 kprobe.function("compat_sys_sendfile64").call ?,
93 kprobe.function("sys32_sendfile").call ?
94 {
95 @_SYSCALL_SENDFILE_NAME
96 asmlinkage()
97 @_SYSCALL_SENDFILE_REGARGS
98 @_SYSCALL_SENDFILE_ARGSTR
99 }
100 probe __nd1_syscall.sendfile = kprobe.function("sys_sendfile").call ?,
101 kprobe.function("sys_sendfile64").call ?
102 {
103 @__syscall_gate2(@const("__NR_sendfile"), @const("__NR_sendfile64"))
104 }
105
106 /* kernel 4.17+ */
107 probe nd2_syscall.sendfile =
108 kprobe.function(@arch_syscall_prefix "sys_sendfile64") ?,
109 kprobe.function(@arch_syscall_prefix "compat_sys_sendfile") ?
110 {
111 __set_syscall_pt_regs(pointer_arg(1))
112 @_SYSCALL_SENDFILE_NAME
113 @_SYSCALL_SENDFILE_REGARGS
114 @_SYSCALL_SENDFILE_ARGSTR
115 },
116 {
117 %( @_IS_SREG_KERNEL %? @_SYSCALL_SENDFILE_REGARGS_STORE %)
118 }
119
120 /* kernel 3.5+, but undesirable because it affects all syscalls */
121 probe tp_syscall.sendfile = kernel.trace("sys_enter")
122 {
123 __set_syscall_pt_regs($regs)
124 @__syscall_compat_gate(@const("__NR_sendfile"), @const("__NR_compat_sendfile"))
125 @_SYSCALL_SENDFILE_NAME
126 @_SYSCALL_SENDFILE_REGARGS
127 @_SYSCALL_SENDFILE_ARGSTR
128 },
129 {
130 %( @_IS_SREG_KERNEL %? @_SYSCALL_SENDFILE_REGARGS_STORE %)
131 }
132
133 probe nd_syscall.sendfile.return = nd1_syscall.sendfile.return!, nd2_syscall.sendfile.return!, tp_syscall.sendfile.return
134 { }
135
136 probe nd1_syscall.sendfile.return = __nd1_syscall.sendfile.return ?,
137 kprobe.function("compat_sys_sendfile").return ?,
138 kprobe.function("compat_sys_sendfile64").return ?,
139 kprobe.function("sys32_sendfile").return ?
140 {
141 @_SYSCALL_SENDFILE_NAME
142 @SYSC_RETVALSTR(returnval())
143 }
144 probe __nd1_syscall.sendfile.return = kprobe.function("sys_sendfile").return ?,
145 kprobe.function("sys_sendfile64").return ?
146 {
147 @__syscall_gate2(@const("__NR_sendfile"), @const("__NR_sendfile64"))
148 }
149
150 /* kernel 4.17+ */
151 probe nd2_syscall.sendfile.return =
152 kprobe.function(@arch_syscall_prefix "sys_sendfile64").return ?,
153 kprobe.function(@arch_syscall_prefix "compat_sys_sendfile").return ?
154 {
155 @_SYSCALL_SENDFILE_NAME
156 @SYSC_RETVALSTR(returnval())
157 }
158
159 /* kernel 3.5+, but undesirable because it affects all syscalls */
160 probe tp_syscall.sendfile.return = kernel.trace("sys_exit")
161 {
162 __set_syscall_pt_regs($regs)
163 @__syscall_compat_gate(@const("__NR_sendfile"), @const("__NR_compat_sendfile"))
164 @_SYSCALL_SENDFILE_NAME
165 @SYSC_RETVALSTR($ret)
166 }