Debian Codegraph @

tapset/linux/sysc_fchown.stp

raw
1 # fchown _____________________________________________________
2 # long sys_fchown(unsigned int fd, uid_t user, gid_t group)
3
4 @define _SYSCALL_FCHOWN_NAME
5 %(
6 name = "fchown"
7 %)
8
9 @define _SYSCALL_FCHOWN_ARGSTR
10 %(
11 argstr = sprintf("%d, %d, %d", fd, owner, group)
12 %)
13
14 @define _SYSCALL_FCHOWN_REGARGS
15 %(
16 fd = int_arg(1)
17 owner = __int32(uint_arg(2))
18 group = __int32(uint_arg(3))
19 %)
20
21 @define _SYSCALL_FCHOWN_REGARGS_STORE
22 %(
23 if (@probewrite(fd))
24 set_int_arg(1, fd)
25
26 if (@probewrite(owner))
27 set_uint_arg(2, __int32(owner))
28
29 if (@probewrite(group))
30 set_uint_arg(3, __int32(group))
31 %)
32
33 probe syscall.fchown = dw_syscall.fchown !, nd_syscall.fchown ? {}
34 probe syscall.fchown.return = dw_syscall.fchown.return !, nd_syscall.fchown.return ? {}
35
36 # dw_fchown _____________________________________________________
37
38 probe dw_syscall.fchown = kernel.function("sys_fchown").call
39 {
40 // Avoid fchown16() calling fchown().
41 %( arch == "x86_64" %?
42 @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32"))
43 %)
44 %( arch == "i386" %?
45 @__syscall_gate(@const("__NR_fchown32"))
46 %)
47 @_SYSCALL_FCHOWN_NAME
48 fd = __int32($fd)
49 owner = __int32($user)
50 group = __int32($group)
51 @_SYSCALL_FCHOWN_ARGSTR
52 }
53 probe dw_syscall.fchown.return = kernel.function("sys_fchown").return
54 {
55 %( arch == "x86_64" %?
56 @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32"))
57 %)
58 %( arch == "i386" %?
59 @__syscall_gate(@const("__NR_fchown32"))
60 %)
61 @_SYSCALL_FCHOWN_NAME
62 @SYSC_RETVALSTR($return)
63 }
64
65 # nd_fchown _____________________________________________________
66
67 probe nd_syscall.fchown = nd1_syscall.fchown!, nd2_syscall.fchown!, tp_syscall.fchown
68 { }
69
70 probe nd1_syscall.fchown = kprobe.function("sys_fchown") ?
71 {
72 // Avoid fchown16() calling fchown().
73 %( arch == "x86_64" %?
74 @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32"))
75 %)
76 %( arch == "i386" %?
77 @__syscall_gate(@const("__NR_fchown32"))
78 %)
79 @_SYSCALL_FCHOWN_NAME
80 asmlinkage()
81 @_SYSCALL_FCHOWN_REGARGS
82 @_SYSCALL_FCHOWN_ARGSTR
83 }
84
85 /* kernel 4.17+ */
86 probe nd2_syscall.fchown = kprobe.function(@arch_syscall_prefix "sys_fchown") ?
87 {
88 __set_syscall_pt_regs(pointer_arg(1))
89 @_SYSCALL_FCHOWN_NAME
90 @_SYSCALL_FCHOWN_REGARGS
91 @_SYSCALL_FCHOWN_ARGSTR
92 },
93 {
94 %( @_IS_SREG_KERNEL %? @_SYSCALL_FCHOWN_REGARGS_STORE %)
95 }
96
97 /* kernel 3.5+, but undesirable because it affects all syscalls */
98 probe tp_syscall.fchown = kernel.trace("sys_enter")
99 {
100 __set_syscall_pt_regs($regs)
101 %( CONFIG_64BIT == "y" %?
102 @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_compat_fchown32"))
103 %:
104 @__syscall_gate(@const("__NR_fchown32"))
105 %)
106 @_SYSCALL_FCHOWN_NAME
107 @_SYSCALL_FCHOWN_REGARGS
108 @_SYSCALL_FCHOWN_ARGSTR
109 },
110 {
111 %( @_IS_SREG_KERNEL %? @_SYSCALL_FCHOWN_REGARGS_STORE %)
112 }
113
114 probe nd_syscall.fchown.return = nd1_syscall.fchown.return!, nd2_syscall.fchown.return!, tp_syscall.fchown.return
115 { }
116
117 probe nd1_syscall.fchown.return = kprobe.function("sys_fchown").return ?
118 {
119 %( arch == "x86_64" %?
120 @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_ia32_fchown32"))
121 %)
122 %( arch == "i386" %?
123 @__syscall_gate(@const("__NR_fchown32"))
124 %)
125 @_SYSCALL_FCHOWN_NAME
126 @SYSC_RETVALSTR(returnval())
127 }
128
129 /* kernel 4.17+ */
130 probe nd2_syscall.fchown.return = kprobe.function(@arch_syscall_prefix "sys_fchown").return ?
131 {
132 @_SYSCALL_FCHOWN_NAME
133 @SYSC_RETVALSTR(returnval())
134 }
135
136 /* kernel 3.5+, but undesirable because it affects all syscalls */
137 probe tp_syscall.fchown.return = kernel.trace("sys_exit")
138 {
139 __set_syscall_pt_regs($regs)
140 %( CONFIG_64BIT == "y" %?
141 @__syscall_compat_gate(@const("__NR_fchown"), @const("__NR_compat_fchown32"))
142 %:
143 @__syscall_gate(@const("__NR_fchown32"))
144 %)
145 @_SYSCALL_FCHOWN_NAME
146 @SYSC_RETVALSTR($ret)
147 }