Debian Codegraph @

tapset/linux/sysc_statfs.stp

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