Debian Codegraph @

tapset/linux/sysc_fcntl.stp

raw
1 # fcntl ______________________________________________________
2 # long sys_fcntl(int fd, unsigned int cmd, unsigned long arg)
3 # long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
4 # long compat_sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
5 # long compat_sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
6 #
7
8 @define _SYSCALL_FCNTL_NAME
9 %(
10 name = "fcntl"
11 %)
12
13 @define _SYSCALL_FCNTL_ARGSTR
14 %(
15 argstr = sprintf("%d, %s, %p", fd, cmd_str, arg)
16 %)
17
18 @define _SYSCALL_FCNTL_REGARGS
19 %(
20 fd = int_arg(1)
21 cmd = int_arg(2)
22 cmd_str = _fcntl_cmd_str(cmd)
23 arg = long_arg(3)
24 %)
25
26 @define _SYSCALL_FCNTL_REGARGS_STORE
27 %(
28 if (@probewrite(fd))
29 set_int_arg(1, fd)
30
31 if (@probewrite(cmd))
32 set_int_arg(2, cmd)
33
34 if (@probewrite(arg))
35 set_long_arg(3, arg)
36 %)
37
38 probe syscall.fcntl = dw_syscall.fcntl !, nd_syscall.fcntl ? {}
39 probe syscall.fcntl.return = dw_syscall.fcntl.return !, nd_syscall.fcntl.return ? {}
40
41 # dw_fcntl _____________________________________________________
42
43 probe dw_syscall.fcntl = __dw_syscall.fcntl,
44 kernel.function("compat_sys_fcntl").call ?,
45 kernel.function("compat_sys_fcntl64").call ?
46 {
47 @_SYSCALL_FCNTL_NAME
48 fd = __int32($fd)
49 cmd = __int32($cmd)
50 cmd_str = _fcntl_cmd_str(cmd)
51 arg = @__pointer($arg)
52 @_SYSCALL_FCNTL_ARGSTR
53 }
54 probe __dw_syscall.fcntl = kernel.function("sys_fcntl64").call ?,
55 kernel.function("sys_fcntl").call ?
56 {
57 @__syscall_gate_compat_simple
58 }
59
60 probe dw_syscall.fcntl.return = __dw_syscall.fcntl.return,
61 kernel.function("compat_sys_fcntl").return ?,
62 kernel.function("compat_sys_fcntl64").return ?
63 {
64 @_SYSCALL_FCNTL_NAME
65 @SYSC_RETVALSTR($return)
66 }
67 probe __dw_syscall.fcntl.return = kernel.function("sys_fcntl64").return ?,
68 kernel.function("sys_fcntl").return ?
69 {
70 @__syscall_gate_compat_simple
71 }
72
73
74 # nd_fcntl _____________________________________________________
75
76 probe nd_syscall.fcntl = nd1_syscall.fcntl!, nd2_syscall.fcntl!, tp_syscall.fcntl
77 { }
78
79 probe nd1_syscall.fcntl = __nd1_syscall.fcntl,
80 kprobe.function("compat_sys_fcntl") ?,
81 kprobe.function("compat_sys_fcntl64") ?
82 {
83 @_SYSCALL_FCNTL_NAME
84 asmlinkage()
85 @_SYSCALL_FCNTL_REGARGS
86 @_SYSCALL_FCNTL_ARGSTR
87 }
88 probe __nd1_syscall.fcntl = kprobe.function("sys_fcntl64") ?,
89 kprobe.function("sys_fcntl") ?
90 {
91 @__syscall_gate_compat_simple
92 }
93
94 /* kernel 4.17+ */
95 probe nd2_syscall.fcntl = kprobe.function(@arch_syscall_prefix "sys_fcntl") ?,
96 kprobe.function(@arch_syscall_prefix "compat_sys_fcntl64") ?
97 {
98 __set_syscall_pt_regs(pointer_arg(1))
99 @_SYSCALL_FCNTL_NAME
100 @_SYSCALL_FCNTL_REGARGS
101 @_SYSCALL_FCNTL_ARGSTR
102 },
103 {
104 %( @_IS_SREG_KERNEL %? @_SYSCALL_FCNTL_REGARGS_STORE %)
105 }
106
107 /* kernel 3.5+, but undesirable because it affects all syscalls */
108 probe tp_syscall.fcntl = __tp_syscall.fcntl, __tp_syscall.fcntl64
109 {
110 __set_syscall_pt_regs($regs)
111 @_SYSCALL_FCNTL_NAME
112 @_SYSCALL_FCNTL_REGARGS
113 @_SYSCALL_FCNTL_ARGSTR
114 },
115 {
116 %( @_IS_SREG_KERNEL %? @_SYSCALL_FCNTL_REGARGS_STORE %)
117 }
118 probe __tp_syscall.fcntl = kernel.trace("sys_enter")
119 {
120 @__syscall_compat_gate(@const("__NR_fcntl"), @const("__NR_compat_fcntl"))
121 }
122 probe __tp_syscall.fcntl64 = kernel.trace("sys_enter")
123 {
124 @__syscall_compat_gate(@const("__NR_fcntl64"), @const("__NR_compat_fcntl64"))
125 }
126
127 probe nd_syscall.fcntl.return = nd1_syscall.fcntl.return!, nd2_syscall.fcntl.return!, tp_syscall.fcntl.return
128 { }
129
130 probe nd1_syscall.fcntl.return = __nd1_syscall.fcntl.return,
131 kprobe.function("compat_sys_fcntl").return ?,
132 kprobe.function("compat_sys_fcntl64").return ?
133 {
134 @_SYSCALL_FCNTL_NAME
135 @SYSC_RETVALSTR(returnval())
136 }
137 probe __nd1_syscall.fcntl.return = kprobe.function("sys_fcntl64").return ?,
138 kprobe.function("sys_fcntl").return ?
139 {
140 @__syscall_gate_compat_simple
141 }
142
143 /* kernel 4.17+ */
144 probe nd2_syscall.fcntl.return = kprobe.function(@arch_syscall_prefix "sys_fcntl").return ?,
145 kprobe.function(@arch_syscall_prefix "compat_sys_fcntl64").return ?
146 {
147 @_SYSCALL_FCNTL_NAME
148 @SYSC_RETVALSTR(returnval())
149 }
150
151 /* kernel 3.5+, but undesirable because it affects all syscalls */
152 probe tp_syscall.fcntl.return = __tp_syscall.fcntl.return, __tp_syscall.fcntl64.return
153 {
154 __set_syscall_pt_regs($regs)
155 @_SYSCALL_FCNTL_NAME
156 @SYSC_RETVALSTR($ret)
157 }
158 probe __tp_syscall.fcntl.return = kernel.trace("sys_exit")
159 {
160 @__syscall_compat_gate(@const("__NR_fcntl"), @const("__NR_compat_fcntl"))
161 }
162 probe __tp_syscall.fcntl64.return = kernel.trace("sys_exit")
163 {
164 @__syscall_compat_gate(@const("__NR_fcntl64"), @const("__NR_compat_fcntl64"))
165 }