Debian Codegraph @

tapset/linux/sysc_getdents.stp

raw
1 # getdents ___________________________________________________
2 # long sys_getdents(unsigned int fd, struct linux_dirent __user * dirent, unsigned int count)
3 # long compat_sys_getdents(unsigned int fd, struct compat_linux_dirent __user *dirent, unsigned int count)
4 # long sys_getdents64(unsigned int fd, struct linux_dirent64 __user * dirent, unsigned int count)
5 # long compat_sys_getdents64(unsigned int fd, struct linux_dirent64 __user * dirent, unsigned int count)
6 #
7
8 @define _SYSCALL_GETDENTS_NAME
9 %(
10 name = "getdents"
11 %)
12
13 @define _SYSCALL_GETDENTS_ARGSTR
14 %(
15 argstr = sprintf("%d, %p, %d", fd, dirp_uaddr, count)
16 %)
17
18 @define _SYSCALL_GATE
19 %(
20 %( arch == "s390" && kernel_v >= "3.15" %?
21 # s390 switched from assembly compat wrappers to C-based
22 # wrappers in kernel 3.15.
23 @__syscall_gate_compat_simple
24 %)
25 %)
26
27 @define _SYSCALL_GETDENTS_REGARGS
28 %(
29 fd = int_arg(1)
30 dirp_uaddr = pointer_arg(2)
31 count = uint_arg(3)
32 %)
33
34 @define _SYSCALL_GETDENTS_REGARGS_STORE
35 %(
36 if (@probewrite(fd))
37 set_int_arg(1, fd)
38
39 if (@probewrite(dirp_uaddr))
40 set_pointer_arg(2, dirp_uaddr)
41
42 if (@probewrite(count))
43 set_uint_arg(3, count)
44 %)
45
46 probe syscall.getdents = dw_syscall.getdents !, nd_syscall.getdents ? {}
47 probe syscall.getdents.return = dw_syscall.getdents.return !,
48 nd_syscall.getdents.return ? {}
49
50 # dw_getdents _____________________________________________________
51
52 probe dw_syscall.getdents = __syscall.getdents ?,
53 kernel.function("compat_sys_getdents").call ?,
54 kernel.function("compat_sys_getdents64").call ?
55 {
56 @_SYSCALL_GETDENTS_NAME
57 fd = __int32($fd)
58 dirp_uaddr = $dirent
59 count = __uint32($count)
60 @_SYSCALL_GETDENTS_ARGSTR
61 }
62 probe __syscall.getdents = kernel.function("sys_getdents").call ?,
63 kernel.function("sys_getdents64").call ?
64 {
65 @_SYSCALL_GATE
66 }
67 probe dw_syscall.getdents.return = __syscall.getdents.return ?,
68 kernel.function("compat_sys_getdents").return ?,
69 kernel.function("compat_sys_getdents64").return ?
70 {
71 @_SYSCALL_GETDENTS_NAME
72 @SYSC_RETVALSTR($return)
73 }
74 probe __syscall.getdents.return = kernel.function("sys_getdents").return ?,
75 kernel.function("sys_getdents64").return ?
76 {
77 @_SYSCALL_GATE
78 }
79
80 # nd_getdents _____________________________________________________
81
82 probe nd_syscall.getdents = nd1_syscall.getdents!, nd2_syscall.getdents!, tp_syscall.getdents
83 { }
84
85 probe nd1_syscall.getdents = __nd1_syscall.getdents ?,
86 kprobe.function("compat_sys_getdents") ?,
87 kprobe.function("compat_sys_getdents64") ?
88 {
89 @_SYSCALL_GETDENTS_NAME
90 asmlinkage()
91 @_SYSCALL_GETDENTS_REGARGS
92 @_SYSCALL_GETDENTS_ARGSTR
93 }
94 probe __nd1_syscall.getdents = kprobe.function("sys_getdents") ?,
95 kprobe.function("sys_getdents64") ?
96 {
97 @_SYSCALL_GATE
98 }
99
100 /* kernel 4.17+ */
101 probe nd2_syscall.getdents = kprobe.function(@arch_syscall_prefix "sys_getdents") ?,
102 kprobe.function(@arch_syscall_prefix "sys_getdents64") ?,
103 kprobe.function(@arch_syscall_prefix "compat_sys_getdents") ?,
104 kprobe.function(@arch_syscall_prefix "compat_sys_getdents64") ?
105 {
106 __set_syscall_pt_regs(pointer_arg(1))
107 @_SYSCALL_GETDENTS_NAME
108 @_SYSCALL_GETDENTS_REGARGS
109 @_SYSCALL_GETDENTS_ARGSTR
110 },
111 {
112 @_SYSCALL_GETDENTS_REGARGS_STORE
113 }
114
115 /* kernel 3.5+, but undesirable because it affects all syscalls */
116 probe tp_syscall.getdents = __tp_syscall.getdents, __tp_syscall.getdents64
117 {
118 __set_syscall_pt_regs($regs)
119 @_SYSCALL_GETDENTS_NAME
120 @_SYSCALL_GETDENTS_REGARGS
121 @_SYSCALL_GETDENTS_ARGSTR
122 },
123 {
124 @_SYSCALL_GETDENTS_REGARGS_STORE
125 }
126 probe __tp_syscall.getdents = kernel.trace("sys_enter")
127 {
128 @__syscall_compat_gate(@const("__NR_getdents"), @const("__NR_compat_getdents"))
129 }
130 probe __tp_syscall.getdents64 = kernel.trace("sys_enter")
131 {
132 @__syscall_compat_gate(@const("__NR_getdents64"), @const("__NR_compat_getdents64"))
133 }
134
135 probe nd_syscall.getdents.return = nd1_syscall.getdents.return!, nd2_syscall.getdents.return!, tp_syscall.getdents.return
136 { }
137
138 probe nd1_syscall.getdents.return = __nd1_syscall.getdents.return ?,
139 kprobe.function("compat_sys_getdents").return ?,
140 kprobe.function("compat_sys_getdents64").return ?
141 {
142 @_SYSCALL_GETDENTS_NAME
143 @SYSC_RETVALSTR(returnval())
144 }
145 probe __nd1_syscall.getdents.return = kprobe.function("sys_getdents").return ?,
146 kprobe.function("sys_getdents64").return ?
147 {
148 @_SYSCALL_GATE
149 }
150
151 /* kernel 4.17+ */
152 probe nd2_syscall.getdents.return = kprobe.function(@arch_syscall_prefix "sys_getdents").return ?,
153 kprobe.function(@arch_syscall_prefix "sys_getdents64").return ?,
154 kprobe.function(@arch_syscall_prefix "compat_sys_getdents").return ?,
155 kprobe.function(@arch_syscall_prefix "compat_sys_getdents64").return ?
156 {
157 @_SYSCALL_GETDENTS_NAME
158 @SYSC_RETVALSTR(returnval())
159 }
160
161 /* kernel 3.5+, but undesirable because it affects all syscalls */
162 probe tp_syscall.getdents.return = __tp_syscall.getdents.return, __tp_syscall.getdents64.return
163 {
164 __set_syscall_pt_regs($regs)
165 @_SYSCALL_GETDENTS_NAME
166 @SYSC_RETVALSTR($ret)
167 }
168 probe __tp_syscall.getdents.return = kernel.trace("sys_exit")
169 {
170 @__syscall_compat_gate(@const("__NR_getdents"), @const("__NR_compat_getdents"))
171 }
172 probe __tp_syscall.getdents64.return = kernel.trace("sys_exit")
173 {
174 @__syscall_compat_gate(@const("__NR_getdents64"), @const("__NR_compat_getdents64"))
175 }