Lines Matching +full:pass +full:- +full:through

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2018-2019 SUSE LLC.
24 * |-- procexe -> /proc/self/exe
25 * |-- procroot -> /proc/self/root
26 * |-- root/
27 * |-- mnt/ [mountpoint]
28 * | |-- self -> ../mnt/
29 * | `-- absself -> /mnt/
30 * |-- etc/
31 * | `-- passwd
32 * |-- creatlink -> /newfile3
33 * |-- reletc -> etc/
34 * |-- relsym -> etc/passwd
35 * |-- absetc -> /etc/
36 * |-- abssym -> /etc/passwd
37 * |-- abscheeky -> /cheeky
38 * `-- cheeky/
39 * |-- absself -> /
40 * |-- self -> ../../root/
41 * |-- garbageself -> /../../root/
42 * |-- passwd -> ../cheeky/../cheeky/../etc/../etc/passwd
43 * |-- abspasswd -> /../cheeky/../cheeky/../etc/../etc/passwd
44 * |-- dotdotlink -> ../../../../../../../../../../../../../../etc/passwd
45 * `-- garbagelink -> /../../../../../../../../../../../../../../etc/passwd
50 char dirname[] = "/tmp/ksft-openat2-testdir.XXXXXX"; in setup_testdir()
56 /* Make the top-level directory. */ in setup_testdir()
63 /* A sub-directory which is actually used for tests. */ in setup_testdir()
114 bool pass; member
140 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
143 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
146 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
149 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
152 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
155 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
158 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
161 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
164 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
168 .out.path = "root", .pass = true }, in test_openat2_opath_tests()
171 .out.path = "etc", .pass = true }, in test_openat2_opath_tests()
174 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
177 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
178 { .name = "[beneath] chained-'..' relative symlink inside $root", in test_openat2_opath_tests()
180 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
183 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
186 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
189 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
192 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
195 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
197 { .name = "[beneath] tricky '..'-chained symlink outside $root", in test_openat2_opath_tests()
199 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
200 { .name = "[beneath] tricky absolute + '..'-chained symlink outside $root", in test_openat2_opath_tests()
202 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
205 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
208 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
211 /* All attempts to cross the dirfd will be scoped-to-root. */ in test_openat2_opath_tests()
214 .out.path = NULL, .pass = true }, in test_openat2_opath_tests()
217 .out.path = NULL, .pass = true }, in test_openat2_opath_tests()
220 .out.path = NULL, .pass = true }, in test_openat2_opath_tests()
223 .out.path = NULL, .pass = true }, in test_openat2_opath_tests()
226 .out.path = "root", .pass = true }, in test_openat2_opath_tests()
229 .out.path = "root", .pass = true }, in test_openat2_opath_tests()
232 .out.path = "root", .pass = true }, in test_openat2_opath_tests()
235 .out.path = "root", .pass = true }, in test_openat2_opath_tests()
238 .out.path = "root", .pass = true }, in test_openat2_opath_tests()
241 .out.path = "etc", .pass = true }, in test_openat2_opath_tests()
244 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
247 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
248 { .name = "[in_root] chained-'..' relative symlink to 'etc/passwd'", in test_openat2_opath_tests()
250 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
251 { .name = "[in_root] chained-'..' absolute + relative symlink to 'etc/passwd'", in test_openat2_opath_tests()
253 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
256 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
259 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
262 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
265 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
266 { .name = "[in_root] tricky '..'-chained symlink outside $root", in test_openat2_opath_tests()
268 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
269 { .name = "[in_root] tricky absolute + '..'-chained symlink outside $root", in test_openat2_opath_tests()
271 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
272 { .name = "[in_root] tricky absolute path + absolute + '..'-chained symlink outside $root", in test_openat2_opath_tests()
274 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
277 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
280 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
283 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
289 .out.path = "newfile1", .pass = true }, in test_openat2_opath_tests()
294 .out.path = "newfile2", .pass = true }, in test_openat2_opath_tests()
299 .out.path = "newfile3", .pass = true }, in test_openat2_opath_tests()
305 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
308 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
311 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
315 .out.path = "mnt", .pass = true }, in test_openat2_opath_tests()
316 { .name = "[no_xdev] cross up through '..'", in test_openat2_opath_tests()
318 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
319 { .name = "[no_xdev] temporary cross up through '..'", in test_openat2_opath_tests()
321 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
324 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
327 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
331 .out.path = "/", .pass = true }, in test_openat2_opath_tests()
334 .out.path = "/", .pass = true }, in test_openat2_opath_tests()
337 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
340 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
341 /* Magic-links are blocked since they can switch vfsmounts. */ in test_openat2_opath_tests()
342 { .name = "[no_xdev] cross through magic-link to self/root", in test_openat2_opath_tests()
344 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
345 { .name = "[no_xdev] cross through magic-link to self/cwd", in test_openat2_opath_tests()
347 .out.err = -EXDEV, .pass = false }, in test_openat2_opath_tests()
348 /* Except magic-link jumps inside the same vfsmount. */ in test_openat2_opath_tests()
349 { .name = "[no_xdev] jump through magic-link to same procfs", in test_openat2_opath_tests()
351 .out.path = "/proc", .pass = true, }, in test_openat2_opath_tests()
357 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
358 /* Magic-links should not work. */ in test_openat2_opath_tests()
359 { .name = "[no_magiclinks] symlink to magic-link", in test_openat2_opath_tests()
361 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
362 { .name = "[no_magiclinks] normal path to magic-link", in test_openat2_opath_tests()
364 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
365 { .name = "[no_magiclinks] normal path to magic-link with O_NOFOLLOW", in test_openat2_opath_tests()
368 .out.path = procselfexe, .pass = true }, in test_openat2_opath_tests()
369 { .name = "[no_magiclinks] symlink to magic-link path component", in test_openat2_opath_tests()
371 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
372 { .name = "[no_magiclinks] magic-link path component", in test_openat2_opath_tests()
374 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
375 { .name = "[no_magiclinks] magic-link path component with O_NOFOLLOW", in test_openat2_opath_tests()
378 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
384 .out.path = NULL, .pass = true }, in test_openat2_opath_tests()
387 .out.path = "root", .pass = true }, in test_openat2_opath_tests()
390 .out.path = "etc", .pass = true }, in test_openat2_opath_tests()
393 .out.path = "etc/passwd", .pass = true }, in test_openat2_opath_tests()
397 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
400 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
403 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
406 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
409 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
412 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
415 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
420 .out.path = "relsym", .pass = true }, in test_openat2_opath_tests()
424 .out.path = "abssym", .pass = true }, in test_openat2_opath_tests()
428 .out.path = "cheeky/garbagelink", .pass = true }, in test_openat2_opath_tests()
432 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
436 .out.err = -ELOOP, .pass = false }, in test_openat2_opath_tests()
454 /* Auto-set O_PATH. */ in test_openat2_opath_tests()
455 if (!(test->how.flags & O_CREAT)) in test_openat2_opath_tests()
456 test->how.flags |= O_PATH; in test_openat2_opath_tests()
458 if (test->dir) in test_openat2_opath_tests()
459 dfd = openat(rootfd, test->dir, O_PATH | O_DIRECTORY); in test_openat2_opath_tests()
462 E_assert(dfd, "failed to openat root '%s': %m", test->dir); in test_openat2_opath_tests()
466 fd = sys_openat2(dfd, test->path, &test->how); in test_openat2_opath_tests()
467 if (test->pass) in test_openat2_opath_tests()
468 failed = (fd < 0 || !fdequal(fd, rootfd, test->out.path)); in test_openat2_opath_tests()
470 failed = (fd != test->out.err); in test_openat2_opath_tests()
484 ksft_print_msg("%d (%s)\n", fd, strerror(-fd)); in test_openat2_opath_tests()
488 if (test->pass) in test_openat2_opath_tests()
489 resultfn("%s gives path '%s'\n", test->name, in test_openat2_opath_tests()
490 test->out.path ?: "."); in test_openat2_opath_tests()
492 resultfn("%s fails with %d (%s)\n", test->name, in test_openat2_opath_tests()
493 test->out.err, strerror(-test->out.err)); in test_openat2_opath_tests()