Debian Codegraph @

tapset/linux/sysc_fchownat.stp

raw
1 # fchownat ___________________________________________________
2 # new function with 2.6.16
3 # long sys_fchownat(int dfd, const char __user *filename,
4 # uid_t user, gid_t group, int flag)
5
6 @define _SYSCALL_FCHOWNAT_NAME
7 %(
8 name = "fchownat"
9 %)
10
11 @define _SYSCALL_FCHOWNAT_ARGSTR
12 %(
13 argstr = sprintf("%s, %s, %d, %d, %s", dirfd_str, pathname, owner,
14 group, flags_str)
15 %)
16
17 @define _SYSCALL_FCHOWNAT_REGARGS
18 %(
19 dirfd = int_arg(1)
20 dirfd_str = _dfd_str(dirfd)
21 pathname = user_string_quoted(pointer_arg(2))
22 pathname_unquoted = user_string_nofault(pointer_arg(2))
23 owner = __int32(uint_arg(3))
24 group = __int32(uint_arg(4))
25 flags = int_arg(5)
26 flags_str = _at_flag_str(flags)
27 %)
28
29 @define _SYSCALL_FCHOWNAT_REGARGS_STORE
30 %(
31 if (@probewrite(dirfd))
32 set_int_arg(1, dirfd)
33
34 if (@probewrite(pathname_unquoted))
35 set_user_string_arg(pointer_arg(2), pathname_unquoted)
36
37 if (@probewrite(owner))
38 set_uint_arg(3, __int32(owner))
39
40 if (@probewrite(group))
41 set_uint_arg(4, __int32(group))
42
43 if (@probewrite(flags))
44 set_int_arg(5, flags)
45 %)
46
47 probe syscall.fchownat = dw_syscall.fchownat !, nd_syscall.fchownat ? {}
48 probe syscall.fchownat.return = dw_syscall.fchownat.return !, nd_syscall.fchownat.return ? {}
49
50 # dw_fchownat _____________________________________________________
51
52 probe dw_syscall.fchownat = kernel.function("sys_fchownat").call ?
53 {
54 @__syscall_compat_gate(@const("__NR_fchownat"),
55 @const("__NR_compat_fchownat"))
56 @_SYSCALL_FCHOWNAT_NAME
57 dirfd = __int32($dfd)
58 dirfd_str = _dfd_str(__int32($dfd))
59 pathname = user_string_quoted($filename)
60 owner = __int32($user)
61 group = __int32($group)
62 flags = __int32($flag)
63 flags_str = _at_flag_str(__int32($flag))
64 @_SYSCALL_FCHOWNAT_ARGSTR
65 }
66 probe dw_syscall.fchownat.return = kernel.function("sys_fchownat").return ?
67 {
68 @__syscall_compat_gate(@const("__NR_fchownat"),
69 @const("__NR_compat_fchownat"))
70 @_SYSCALL_FCHOWNAT_NAME
71 @SYSC_RETVALSTR($return)
72 }
73
74 # nd_fchownat _____________________________________________________
75
76 probe nd_syscall.fchownat = nd1_syscall.fchownat!, nd2_syscall.fchownat!, tp_syscall.fchownat
77 { }
78
79 probe nd1_syscall.fchownat = kprobe.function("sys_fchownat") ?
80 {
81 @__syscall_compat_gate(@const("__NR_fchownat"),
82 @const("__NR_compat_fchownat"))
83 @_SYSCALL_FCHOWNAT_NAME
84 asmlinkage()
85 @_SYSCALL_FCHOWNAT_REGARGS
86 @_SYSCALL_FCHOWNAT_ARGSTR
87 }
88
89 /* kernel 4.17+ */
90 probe nd2_syscall.fchownat = kprobe.function(@arch_syscall_prefix "sys_fchownat") ?
91 {
92 __set_syscall_pt_regs(pointer_arg(1))
93 @_SYSCALL_FCHOWNAT_NAME
94 @_SYSCALL_FCHOWNAT_REGARGS
95 @_SYSCALL_FCHOWNAT_ARGSTR
96 },
97 {
98 %( @_IS_SREG_KERNEL %? @_SYSCALL_FCHOWNAT_REGARGS_STORE %)
99 }
100
101 /* kernel 3.5+, but undesirable because it affects all syscalls */
102 probe tp_syscall.fchownat = kernel.trace("sys_enter")
103 {
104 __set_syscall_pt_regs($regs)
105 @__syscall_compat_gate(@const("__NR_fchownat"), @const("__NR_compat_fchownat"))
106 @_SYSCALL_FCHOWNAT_NAME
107 @_SYSCALL_FCHOWNAT_REGARGS
108 @_SYSCALL_FCHOWNAT_ARGSTR
109 },
110 {
111 %( @_IS_SREG_KERNEL %? @_SYSCALL_FCHOWNAT_REGARGS_STORE %)
112 }
113
114 probe nd_syscall.fchownat.return = nd1_syscall.fchownat.return!, nd2_syscall.fchownat.return!, tp_syscall.fchownat.return
115 { }
116
117 probe nd1_syscall.fchownat.return = kprobe.function("sys_fchownat").return ?
118 {
119 @__syscall_compat_gate(@const("__NR_fchownat"),
120 @const("__NR_compat_fchownat"))
121 @_SYSCALL_FCHOWNAT_NAME
122 @SYSC_RETVALSTR(returnval())
123 }
124
125 /* kernel 4.17+ */
126 probe nd2_syscall.fchownat.return = kprobe.function(@arch_syscall_prefix "sys_fchownat").return ?
127 {
128 @_SYSCALL_FCHOWNAT_NAME
129 @SYSC_RETVALSTR(returnval())
130 }
131
132 /* kernel 3.5+, but undesirable because it affects all syscalls */
133 probe tp_syscall.fchownat.return = kernel.trace("sys_exit")
134 {
135 __set_syscall_pt_regs($regs)
136 @__syscall_compat_gate(@const("__NR_fchownat"), @const("__NR_compat_fchownat"))
137 @_SYSCALL_FCHOWNAT_NAME
138 @SYSC_RETVALSTR($ret)
139 }