@@ -86,16 +86,9 @@ static int get_yama_ptrace_scope(void)
8686}
8787
8888/* clang-format off */
89- FIXTURE (hierarchy ) {};
89+ FIXTURE (scoped_domains ) {};
9090/* clang-format on */
9191
92- FIXTURE_VARIANT (hierarchy )
93- {
94- const bool domain_both ;
95- const bool domain_parent ;
96- const bool domain_child ;
97- };
98-
9992/*
10093 * Test multiple tracing combinations between a parent process P1 and a child
10194 * process P2.
@@ -104,155 +97,18 @@ FIXTURE_VARIANT(hierarchy)
10497 * restriction is enforced in addition to any Landlock check, which means that
10598 * all P2 requests to trace P1 would be denied.
10699 */
100+ #include "scoped_base_variants.h"
107101
108- /*
109- * No domain
110- *
111- * P1-. P1 -> P2 : allow
112- * \ P2 -> P1 : allow
113- * 'P2
114- */
115- /* clang-format off */
116- FIXTURE_VARIANT_ADD (hierarchy , allow_without_domain ) {
117- /* clang-format on */
118- .domain_both = false,
119- .domain_parent = false,
120- .domain_child = false,
121- };
122-
123- /*
124- * Child domain
125- *
126- * P1--. P1 -> P2 : allow
127- * \ P2 -> P1 : deny
128- * .'-----.
129- * | P2 |
130- * '------'
131- */
132- /* clang-format off */
133- FIXTURE_VARIANT_ADD (hierarchy , allow_with_one_domain ) {
134- /* clang-format on */
135- .domain_both = false,
136- .domain_parent = false,
137- .domain_child = true,
138- };
139-
140- /*
141- * Parent domain
142- * .------.
143- * | P1 --. P1 -> P2 : deny
144- * '------' \ P2 -> P1 : allow
145- * '
146- * P2
147- */
148- /* clang-format off */
149- FIXTURE_VARIANT_ADD (hierarchy , deny_with_parent_domain ) {
150- /* clang-format on */
151- .domain_both = false,
152- .domain_parent = true,
153- .domain_child = false,
154- };
155-
156- /*
157- * Parent + child domain (siblings)
158- * .------.
159- * | P1 ---. P1 -> P2 : deny
160- * '------' \ P2 -> P1 : deny
161- * .---'--.
162- * | P2 |
163- * '------'
164- */
165- /* clang-format off */
166- FIXTURE_VARIANT_ADD (hierarchy , deny_with_sibling_domain ) {
167- /* clang-format on */
168- .domain_both = false,
169- .domain_parent = true,
170- .domain_child = true,
171- };
172-
173- /*
174- * Same domain (inherited)
175- * .-------------.
176- * | P1----. | P1 -> P2 : allow
177- * | \ | P2 -> P1 : allow
178- * | ' |
179- * | P2 |
180- * '-------------'
181- */
182- /* clang-format off */
183- FIXTURE_VARIANT_ADD (hierarchy , allow_sibling_domain ) {
184- /* clang-format on */
185- .domain_both = true,
186- .domain_parent = false,
187- .domain_child = false,
188- };
189-
190- /*
191- * Inherited + child domain
192- * .-----------------.
193- * | P1----. | P1 -> P2 : allow
194- * | \ | P2 -> P1 : deny
195- * | .-'----. |
196- * | | P2 | |
197- * | '------' |
198- * '-----------------'
199- */
200- /* clang-format off */
201- FIXTURE_VARIANT_ADD (hierarchy , allow_with_nested_domain ) {
202- /* clang-format on */
203- .domain_both = true,
204- .domain_parent = false,
205- .domain_child = true,
206- };
207-
208- /*
209- * Inherited + parent domain
210- * .-----------------.
211- * |.------. | P1 -> P2 : deny
212- * || P1 ----. | P2 -> P1 : allow
213- * |'------' \ |
214- * | ' |
215- * | P2 |
216- * '-----------------'
217- */
218- /* clang-format off */
219- FIXTURE_VARIANT_ADD (hierarchy , deny_with_nested_and_parent_domain ) {
220- /* clang-format on */
221- .domain_both = true,
222- .domain_parent = true,
223- .domain_child = false,
224- };
225-
226- /*
227- * Inherited + parent and child domain (siblings)
228- * .-----------------.
229- * | .------. | P1 -> P2 : deny
230- * | | P1 . | P2 -> P1 : deny
231- * | '------'\ |
232- * | \ |
233- * | .--'---. |
234- * | | P2 | |
235- * | '------' |
236- * '-----------------'
237- */
238- /* clang-format off */
239- FIXTURE_VARIANT_ADD (hierarchy , deny_with_forked_domain ) {
240- /* clang-format on */
241- .domain_both = true,
242- .domain_parent = true,
243- .domain_child = true,
244- };
245-
246- FIXTURE_SETUP (hierarchy )
102+ FIXTURE_SETUP (scoped_domains )
247103{
248104}
249105
250- FIXTURE_TEARDOWN (hierarchy )
106+ FIXTURE_TEARDOWN (scoped_domains )
251107{
252108}
253109
254110/* Test PTRACE_TRACEME and PTRACE_ATTACH for parent and child. */
255- TEST_F (hierarchy , trace )
111+ TEST_F (scoped_domains , trace )
256112{
257113 pid_t child , parent ;
258114 int status , err_proc_read ;
0 commit comments