Debian Codegraph @

tapset/linux/sysc_fgetxattr.stp

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