Debian Codegraph @

tapset/linux/sysc_statfs64.stp

raw
1 # statfs64 ___________________________________________________
2 #
3 # long sys_statfs64(const char __user *path, size_t sz, struct statfs64 __user *buf)
4 # long compat_sys_statfs64(const char __user *path, compat_size_t sz, struct compat_statfs64 __user *buf)
5 #
6
7 @define _SYSCALL_STATFS64_NAME
8 %(
9 name = "statfs64"
10 %)
11
12 @define _SYSCALL_STATFS64_ARGSTR
13 %(
14 argstr = sprintf("%s, %u, %p", path, sz, buf_uaddr)
15 %)
16
17 @define _SYSCALL_STATFS64_REGARGS
18 %(
19 path = user_string_quoted(pointer_arg(1))
20 path_unquoted = user_string_nofault(pointer_arg(1))
21 sz = ulong_arg(2)
22 buf_uaddr = pointer_arg(3)
23 %)
24
25 @define _SYSCALL_STATFS64_REGARGS_STORE
26 %(
27 if (@probewrite(path_unquoted))
28 set_user_string_arg(pointer_arg(1), path_unquoted)
29
30 if (@probewrite(sz))
31 set_ulong_arg(2, sz)
32
33 if (@probewrite(buf_uaddr))
34 set_pointer_arg(3, buf_uaddr)
35 %)
36
37 probe syscall.statfs64 = dw_syscall.statfs64 !, nd_syscall.statfs64 ? {}
38 probe syscall.statfs64.return = dw_syscall.statfs64.return !,
39 nd_syscall.statfs64.return ? {}
40
41 # dw_statfs64 _____________________________________________________
42
43 probe dw_syscall.statfs64 = kernel.function("sys_statfs64").call ?,
44 kernel.function("compat_sys_statfs64").call ?
45 {
46 @_SYSCALL_STATFS64_NAME
47 path = user_string_quoted(@__pointer(@choose_defined($pathname, $path)))
48 sz = __ulong($sz)
49 buf_uaddr = @__pointer($buf)
50 @_SYSCALL_STATFS64_ARGSTR
51 }
52 probe dw_syscall.statfs64.return = kernel.function("sys_statfs64").return ?,
53 kernel.function("compat_sys_statfs64").return ?
54 {
55 @_SYSCALL_STATFS64_NAME
56 @SYSC_RETVALSTR($return)
57 }
58
59 # nd_statfs64 _____________________________________________________
60
61 probe nd_syscall.statfs64 = nd1_syscall.statfs64!, nd2_syscall.statfs64!, tp_syscall.statfs64
62 { }
63
64 probe nd1_syscall.statfs64 = kprobe.function("sys_statfs64") ?,
65 kprobe.function("compat_sys_statfs64") ?
66 {
67 @_SYSCALL_STATFS64_NAME
68 asmlinkage()
69 @_SYSCALL_STATFS64_REGARGS
70 @_SYSCALL_STATFS64_ARGSTR
71 }
72
73 /* kernel 4.17+ */
74 probe nd2_syscall.statfs64 =
75 kprobe.function(@arch_syscall_prefix "compat_sys_statfs64") ?
76 {
77 __set_syscall_pt_regs(pointer_arg(1))
78 @_SYSCALL_STATFS64_NAME
79 @_SYSCALL_STATFS64_REGARGS
80 @_SYSCALL_STATFS64_ARGSTR
81 },
82 {
83 %( @_IS_SREG_KERNEL %? @_SYSCALL_STATFS64_REGARGS_STORE %)
84 }
85
86 /* kernel 3.5+, but undesirable because it affects all syscalls */
87 probe tp_syscall.statfs64 = kernel.trace("sys_enter")
88 {
89 __set_syscall_pt_regs($regs)
90 @__syscall_compat_gate(@const("__NR_statfs64"), @const("__NR_compat_statfs64"))
91 @_SYSCALL_STATFS64_NAME
92 @_SYSCALL_STATFS64_REGARGS
93 @_SYSCALL_STATFS64_ARGSTR
94 },
95 {
96 %( @_IS_SREG_KERNEL %? @_SYSCALL_STATFS64_REGARGS_STORE %)
97 }
98
99 probe nd_syscall.statfs64.return = nd1_syscall.statfs64.return!, nd2_syscall.statfs64.return!, tp_syscall.statfs64.return
100 { }
101
102 probe nd1_syscall.statfs64.return =
103 kprobe.function("sys_statfs64").return ?,
104 kprobe.function("compat_sys_statfs64").return ?
105 {
106 @_SYSCALL_STATFS64_NAME
107 @SYSC_RETVALSTR(returnval())
108 }
109
110 /* kernel 4.17+ */
111 probe nd2_syscall.statfs64.return =
112 kprobe.function(@arch_syscall_prefix "compat_sys_statfs64").return ?
113 {
114 @_SYSCALL_STATFS64_NAME
115 @SYSC_RETVALSTR(returnval())
116 }
117
118 /* kernel 3.5+, but undesirable because it affects all syscalls */
119 probe tp_syscall.statfs64.return = kernel.trace("sys_exit")
120 {
121 __set_syscall_pt_regs($regs)
122 @__syscall_compat_gate(@const("__NR_statfs64"), @const("__NR_compat_statfs64"))
123 @_SYSCALL_STATFS64_NAME
124 @SYSC_RETVALSTR($ret)
125 }