Debian Codegraph @

tapset/linux/sysc_setfsgid.stp

raw
1 # setfsgid ___________________________________________________
2 # long sys_setfsgid(gid_t gid)
3 # long sys_setfsgid16(old_gid_t gid)
4 #
5
6 @define _SYSCALL_SETFSGID_NAME
7 %(
8 name = "setfsgid"
9 %)
10
11 @define _SYSCALL_SETFSGID_ARGSTR
12 %(
13 argstr = sprint(fsgid)
14 %)
15
16 @define _SYSCALL_GATE
17 %(
18 %( arch == "x86_64" %?
19 // There are actually 3 x86_64 setfsgid syscalls numbers (which
20 // get mapped to 2 syscall functions:
21 // - __NR_setfsgid which gets mapped to sys_setfsgid()
22 // - __NR_ia32_setfsgid32 which also gets mapped to
23 // sys_setfsgid()
24 // - __NR_ia32_setfsgid which gets mapped to sys_setfsgid16()
25 // (which is a wrapper around sys_setfsgid())
26 // So, we need to avoid sys_setfsgid() calls that come from
27 // sys_setfsgid16().
28 @__syscall_compat_gate(@const("__NR_setfsgid"),
29 @const("__NR_ia32_setfsgid32"))
30 %:
31 %( arch == "i386" %?
32 // On i386, there are 2 setfsgid syscall numbers:
33 // - __NR_setfsgid which gets mapped to sys_setfsgid16
34 // - __NR_setfsgid32 which gets mapped to sys_setfsgid
35 // Since this gets called from a probe on sys_setfsgid, we'll
36 // make sure this is really __NR_setfsgid32.
37 @__syscall_nr_gate(@const("__NR_setfsgid32"))
38 %)
39 %)
40 %)
41
42 @define _SYSCALL_SETFSGID_REGARGS
43 %(
44 fsgid = int_arg(1)
45 %)
46
47 @define _SYSCALL_SETFSGID_REGARGS_STORE
48 %(
49 if (@probewrite(fsgid))
50 set_int_arg(1, fsgid)
51 %)
52
53 probe syscall.setfsgid = dw_syscall.setfsgid !, nd_syscall.setfsgid ? {}
54 probe syscall.setfsgid.return = dw_syscall.setfsgid.return !,
55 nd_syscall.setfsgid.return ? {}
56
57 # dw_setfsgid _____________________________________________________
58
59 probe dw_syscall.setfsgid = kernel.function("sys_setfsgid16").call ?,
60 __syscall.setfsgid ?
61 {
62 @_SYSCALL_SETFSGID_NAME
63 fsgid = __int32($gid)
64 @_SYSCALL_SETFSGID_ARGSTR
65 }
66 probe __syscall.setfsgid = kernel.function("sys_setfsgid").call ?
67 {
68 @_SYSCALL_GATE
69 }
70 probe dw_syscall.setfsgid.return = kernel.function("sys_setfsgid16").return ?,
71 __syscall.setfsgid.return ?
72 {
73 @_SYSCALL_SETFSGID_NAME
74 @SYSC_RETVALSTR($return)
75 }
76 probe __syscall.setfsgid.return = kernel.function("sys_setfsgid").return ?
77 {
78 @_SYSCALL_GATE
79 }
80
81 # nd_setfsgid _____________________________________________________
82
83 probe nd_syscall.setfsgid = nd1_syscall.setfsgid!, nd2_syscall.setfsgid!, tp_syscall.setfsgid
84 { }
85
86 probe nd1_syscall.setfsgid = kprobe.function("sys_setfsgid16") ?,
87 __nd1_syscall.setfsgid ?
88 {
89 @_SYSCALL_SETFSGID_NAME
90 asmlinkage()
91 @_SYSCALL_SETFSGID_REGARGS
92 @_SYSCALL_SETFSGID_ARGSTR
93 }
94 probe __nd1_syscall.setfsgid = kprobe.function("sys_setfsgid") ?
95 {
96 @_SYSCALL_GATE
97 }
98
99 /* kernel 4.17+ */
100 probe nd2_syscall.setfsgid = kprobe.function(@arch_syscall_prefix "sys_setfsgid") ?,
101 kprobe.function(@arch_syscall_prefix "sys_setfsgid16") ?
102 {
103 __set_syscall_pt_regs(pointer_arg(1))
104 @_SYSCALL_SETFSGID_NAME
105 @_SYSCALL_SETFSGID_REGARGS
106 @_SYSCALL_SETFSGID_ARGSTR
107 },
108 {
109 %( @_IS_SREG_KERNEL %? @_SYSCALL_SETFSGID_REGARGS_STORE %)
110 }
111
112 /* kernel 3.5+, but undesirable because it affects all syscalls */
113 probe tp_syscall.setfsgid = __tp_syscall.setfsgid, __tp_syscall.setfsgid16
114 {
115 __set_syscall_pt_regs($regs)
116 @_SYSCALL_SETFSGID_NAME
117 @_SYSCALL_SETFSGID_REGARGS
118 @_SYSCALL_SETFSGID_ARGSTR
119 },
120 {
121 %( @_IS_SREG_KERNEL %? @_SYSCALL_SETFSGID_REGARGS_STORE %)
122 }
123 probe __tp_syscall.setfsgid = kernel.trace("sys_enter")
124 {
125 @__syscall_compat_gate(@const("__NR_setfsgid"), @const("__NR_compat_setfsgid32"))
126 }
127 probe __tp_syscall.setfsgid16 = kernel.trace("sys_enter")
128 {
129 @__compat_syscall_gate(@const("__NR_compat_setfsgid"))
130 }
131
132 probe nd_syscall.setfsgid.return = nd1_syscall.setfsgid.return!, nd2_syscall.setfsgid.return!, tp_syscall.setfsgid.return
133 { }
134
135 probe nd1_syscall.setfsgid.return = kprobe.function("sys_setfsgid16").return ?,
136 __nd1_syscall.setfsgid.return ?
137 {
138 @_SYSCALL_SETFSGID_NAME
139 @SYSC_RETVALSTR(returnval())
140 }
141 probe __nd1_syscall.setfsgid.return = kprobe.function("sys_setfsgid").return ?
142 {
143 @_SYSCALL_GATE
144 }
145
146 /* kernel 4.17+ */
147 probe nd2_syscall.setfsgid.return =
148 kprobe.function(@arch_syscall_prefix "sys_setfsgid").return ?,
149 kprobe.function(@arch_syscall_prefix "sys_setfsgid16").return ?
150 {
151 @_SYSCALL_SETFSGID_NAME
152 @SYSC_RETVALSTR(returnval())
153 }
154
155 /* kernel 3.5+, but undesirable because it affects all syscalls */
156 probe tp_syscall.setfsgid.return = __tp_syscall.setfsgid.return, __tp_syscall.setfsgid16.return
157 {
158 __set_syscall_pt_regs($regs)
159 @_SYSCALL_SETFSGID_NAME
160 @SYSC_RETVALSTR($ret)
161 }
162 probe __tp_syscall.setfsgid.return = kernel.trace("sys_exit")
163 {
164 @__syscall_compat_gate(@const("__NR_setfsgid"), @const("__NR_compat_setfsgid32"))
165 }
166 probe __tp_syscall.setfsgid16.return = kernel.trace("sys_exit")
167 {
168 @__compat_syscall_gate(@const("__NR_compat_setfsgid"))
169 }