Debian Codegraph @

tapset/linux/sysc_getxattr.stp

raw
1 # getxattr ___________________________________________________
2 # ssize_t sys_getxattr(char __user *path, char __user *name,
3 # void __user *value, size_t size)
4
5 @define _SYSCALL_GETXATTR_NAME
6 %(
7 name = "getxattr"
8 %)
9
10 @define _SYSCALL_GETXATTR_ARGSTR
11 %(
12 argstr = sprintf("%s, %s, %p, %u", path, name_str, value_uaddr, size)
13 %)
14
15 @define _SYSCALL_GETXATTR_REGARGS
16 %(
17 path = user_string_quoted(pointer_arg(1))
18 path_unquoted = user_string_nofault(pointer_arg(1))
19 # 'name2' should have been 'name_str'. Deprecate the old name.
20 %(systemtap_v <= "1.4" %?
21 name2 = user_string_quoted(pointer_arg(2))
22 name2_unquoted = user_string_nofault(pointer_arg(2))
23 %)
24 name_str = user_string_quoted(pointer_arg(2))
25 name_str_unquoted = user_string_nofault(pointer_arg(2))
26 value_uaddr = pointer_arg(3)
27 size = ulong_arg(4)
28 %)
29
30 @define _SYSCALL_GETXATTR_REGARGS_STORE
31 %(
32 if (@probewrite(path_unquoted))
33 set_user_string_arg(pointer_arg(1), path_unquoted)
34
35 %(systemtap_v <= "1.4" %?
36 if (@probewrite(name2_unquoted))
37 set_user_string_arg(pointer_arg(2), name2_unquoted)
38 %)
39
40 if (@probewrite(name_str_unquoted))
41 set_user_string_arg(pointer_arg(2), name_str_unquoted)
42
43 if (@probewrite(value_uaddr))
44 set_pointer_arg(3, value_uaddr)
45
46 if (@probewrite(size))
47 set_ulong_arg(4, size)
48 %)
49
50 probe syscall.getxattr = dw_syscall.getxattr !,
51 nd_syscall.getxattr ? {}
52 probe syscall.getxattr.return = dw_syscall.getxattr.return !,
53 nd_syscall.getxattr.return ? {}
54
55 # dw_getxattr _____________________________________________________
56
57 probe dw_syscall.getxattr = kernel.function("sys_getxattr").call
58 {
59 @_SYSCALL_GETXATTR_NAME
60 path = user_string_quoted(@choose_defined($pathname, $path))
61 # 'name2' should have been 'name_str'. Deprecate the old name.
62 %(systemtap_v <= "1.4" %?
63 name2 = user_string_quoted($name)
64 %)
65 name_str = user_string_quoted($name)
66 value_uaddr = $value
67 size = __ulong($size)
68 @_SYSCALL_GETXATTR_ARGSTR
69 }
70 probe dw_syscall.getxattr.return = kernel.function("sys_getxattr").return
71 {
72 @_SYSCALL_GETXATTR_NAME
73 @SYSC_RETVALSTR($return)
74 }
75
76 # nd_getxattr _____________________________________________________
77
78 probe nd_syscall.getxattr = nd1_syscall.getxattr!, nd2_syscall.getxattr!, tp_syscall.getxattr
79 { }
80
81 probe nd1_syscall.getxattr = kprobe.function("sys_getxattr") ?
82 {
83 @_SYSCALL_GETXATTR_NAME
84 asmlinkage()
85 @_SYSCALL_GETXATTR_REGARGS
86 @_SYSCALL_GETXATTR_ARGSTR
87 }
88
89 /* kernel 4.17+ */
90 probe nd2_syscall.getxattr = kprobe.function(@arch_syscall_prefix "sys_getxattr") ?
91 {
92 __set_syscall_pt_regs(pointer_arg(1))
93 @_SYSCALL_GETXATTR_NAME
94 @_SYSCALL_GETXATTR_REGARGS
95 @_SYSCALL_GETXATTR_ARGSTR
96 },
97 {
98 @_SYSCALL_GETXATTR_REGARGS_STORE
99 }
100
101 /* kernel 3.5+, but undesirable because it affects all syscalls */
102 probe tp_syscall.getxattr = kernel.trace("sys_enter")
103 {
104 __set_syscall_pt_regs($regs)
105 @__syscall_compat_gate(@const("__NR_getxattr"), @const("__NR_compat_getxattr"))
106 @_SYSCALL_GETXATTR_NAME
107 @_SYSCALL_GETXATTR_REGARGS
108 @_SYSCALL_GETXATTR_ARGSTR
109 },
110 {
111 @_SYSCALL_GETXATTR_REGARGS_STORE
112 }
113
114 probe nd_syscall.getxattr.return = nd1_syscall.getxattr.return!, nd2_syscall.getxattr.return!, tp_syscall.getxattr.return
115 { }
116
117 probe nd1_syscall.getxattr.return = kprobe.function("sys_getxattr").return ?
118 {
119 @_SYSCALL_GETXATTR_NAME
120 @SYSC_RETVALSTR(returnval())
121 }
122
123 /* kernel 4.17+ */
124 probe nd2_syscall.getxattr.return = kprobe.function(@arch_syscall_prefix "sys_getxattr").return ?
125 {
126 @_SYSCALL_GETXATTR_NAME
127 @SYSC_RETVALSTR(returnval())
128 }
129
130 /* kernel 3.5+, but undesirable because it affects all syscalls */
131 probe tp_syscall.getxattr.return = kernel.trace("sys_exit")
132 {
133 __set_syscall_pt_regs($regs)
134 @__syscall_compat_gate(@const("__NR_getxattr"), @const("__NR_compat_getxattr"))
135 @_SYSCALL_GETXATTR_NAME
136 @SYSC_RETVALSTR($ret)
137 }