fchroot: add fchroot() testing suite
v2 cover fchroot: add fchroot() testing suite
fchroot() is a new syscall introduced in the Linux v7.3 development cycle together with failfs, a kernel internal filesystem where every operation fails with EOPNOTSUPP. The syscall is the fd-based counterpart of chroot(2): it moves the process root to the directory referenced by a file descriptor, or to the failfs root via the FD_FAILFS_ROOT sentinel.
The series first updates the architecture syscall number tables and adds lapi fallback definitions for the new fd sentinels, then adds 13 tests covering:
- the basic directory fd use case and the argument error paths (EINVAL, EBADF, ENOTDIR)
- the permission checks, both execute permission and CAP_SYS_CHROOT
- entering failfs as root: EOPNOTSUPP on every absolute lookup, unreachable working directory, root that can not be referenced or pinned, path walks anchored at file descriptors, execve blocked, fork inheritance and the setns() escape
- the unprivileged entry rules: no_new_privs, shared fs_struct and the already chrooted case
fchroot() is not part of any released kernel yet, so the tests are added to runtest/staging and each patch carries the [STAGING] prefix as required by the LTP ground rules.
The testing suite creation has been assisted by GLM 5.3.
---
Changes in v2:
- make description more readable
- invert fork() logic for the main test process
- fix the issues found by the agent
- Link to v1: https://lore.kernel.org/[email protected]
To: Linux Test Project <[email protected]>
---
Andrea Cervesato (16):
syscalls: add v7.3 syscall numbers
syscalls: update outdated syscall entries [STAGING] lapi: fallback fchroot() parameters [STAGING] fchroot01: test fchroot() with a directory fd [STAGING] fchroot02: test fchroot() invalid arguments [STAGING] fchroot03: test fchroot() permission checks [STAGING] fchroot04: test fchroot() into failfs as root [STAGING] fchroot05: test failfs root can not be referenced [STAGING] fchroot06: test path walks under failfs root [STAGING] fchroot07: test execve blocked by failfs root [STAGING] fchroot08: test failfs root fork inheritance [STAGING] fchroot09: test setns escape from failfs root [STAGING] fchroot10: test failfs entry without no_new_privs [STAGING] fchroot11: test failfs entry with no_new_privs [STAGING] fchroot12: test failfs entry with shared fs_struct [STAGING] fchroot13: test failfs entry when chrooted
include/lapi/fcntl.h | 13 +++ include/lapi/syscalls/arc.in | 3 + include/lapi/syscalls/arm.in | 4 +- include/lapi/syscalls/arm64.in | 3 + include/lapi/syscalls/i386.in | 4 +- include/lapi/syscalls/loongarch64.in | 3 + include/lapi/syscalls/mips64.in | 5 +- include/lapi/syscalls/mips64n32.in | 5 +- include/lapi/syscalls/mipso32.in | 5 +- include/lapi/syscalls/parisc.in | 4 +- include/lapi/syscalls/powerpc.in | 4 +- include/lapi/syscalls/powerpc64.in | 4 +- include/lapi/syscalls/s390.in | 5 +- include/lapi/syscalls/s390x.in | 5 +- include/lapi/syscalls/sh.in | 4 +- include/lapi/syscalls/sparc.in | 5 +- include/lapi/syscalls/sparc64.in | 5 +- include/lapi/syscalls/x86_64.in | 5 +- runtest/staging | 14 +++ testcases/kernel/syscalls/fchroot/.gitignore | 13 +++ testcases/kernel/syscalls/fchroot/Makefile | 7 ++ testcases/kernel/syscalls/fchroot/fchroot01.c | 59 +++++++++++++ testcases/kernel/syscalls/fchroot/fchroot02.c | 80 ++++++++++++++++++ testcases/kernel/syscalls/fchroot/fchroot03.c | 78 +++++++++++++++++ testcases/kernel/syscalls/fchroot/fchroot04.c | 70 +++++++++++++++ testcases/kernel/syscalls/fchroot/fchroot05.c | 75 +++++++++++++++++ testcases/kernel/syscalls/fchroot/fchroot06.c | 117 ++++++++++++++++++++++++++ testcases/kernel/syscalls/fchroot/fchroot07.c | 72 ++++++++++++++++ testcases/kernel/syscalls/fchroot/fchroot08.c | 69 +++++++++++++++ testcases/kernel/syscalls/fchroot/fchroot09.c | 87 +++++++++++++++++++ testcases/kernel/syscalls/fchroot/fchroot10.c | 50 +++++++++++ testcases/kernel/syscalls/fchroot/fchroot11.c | 70 +++++++++++++++ testcases/kernel/syscalls/fchroot/fchroot12.c | 85 +++++++++++++++++++ testcases/kernel/syscalls/fchroot/fchroot13.c | 63 ++++++++++++++ 34 files changed, 1076 insertions(+), 19 deletions(-)
---
base-commit: 567528e2f809c1309802433703c083bd15ab81a8
change-id: 20260819-fchroot-66115fd0d497
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/16 syscalls: add v7.3 syscall numbers
From: Andrea Cervesato <[email protected]>
Add listns (470), rseq_slice_yield (471) and fchroot (472), which are reserved for all architectures during the Linux v7.3 development cycle.
--- include/lapi/syscalls/arc.in | 3 +++ include/lapi/syscalls/arm.in | 3 +++ include/lapi/syscalls/arm64.in | 3 +++ include/lapi/syscalls/i386.in | 3 +++ include/lapi/syscalls/loongarch64.in | 3 +++ include/lapi/syscalls/mips64.in | 3 +++ include/lapi/syscalls/mips64n32.in | 3 +++ include/lapi/syscalls/mipso32.in | 3 +++ include/lapi/syscalls/parisc.in | 3 +++ include/lapi/syscalls/powerpc.in | 3 +++ include/lapi/syscalls/powerpc64.in | 3 +++ include/lapi/syscalls/s390.in | 3 +++ include/lapi/syscalls/s390x.in | 3 +++ include/lapi/syscalls/sh.in | 3 +++ include/lapi/syscalls/sparc.in | 3 +++ include/lapi/syscalls/sparc64.in | 3 +++ include/lapi/syscalls/x86_64.in | 3 +++ 17 files changed, 51 insertions(+)
include/lapi/syscalls/arc.in +3 -0
@@ -347,3 +347,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/arm.in +3 -0
@@ -420,3 +420,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/arm64.in +3 -0
@@ -323,3 +323,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/i386.in +3 -0
@@ -454,3 +454,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/loongarch64.in +3 -0
@@ -320,3 +320,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/mips64.in +3 -0
@@ -369,3 +369,6 @@ removexattrat 5466 open_tree_attr 5467 file_getattr 5468 file_setattr 5469 +listns 5470 +rseq_slice_yield 5471 +fchroot 5472
include/lapi/syscalls/mips64n32.in +3 -0
@@ -393,3 +393,6 @@ removexattrat 6466 open_tree_attr 6467 file_getattr 6468 file_setattr 6469 +listns 6470 +rseq_slice_yield 6471 +fchroot 6472
include/lapi/syscalls/mipso32.in +3 -0
@@ -433,3 +433,6 @@ removexattrat 4466 open_tree_attr 4467 file_getattr 4468 file_setattr 4469 +listns 4470 +rseq_slice_yield 4471 +fchroot 4472
include/lapi/syscalls/parisc.in +3 -0
@@ -402,3 +402,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/powerpc.in +3 -0
@@ -444,3 +444,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/powerpc64.in +3 -0
@@ -416,3 +416,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/s390.in +3 -0
@@ -437,3 +437,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/s390x.in +3 -0
@@ -385,3 +385,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/sh.in +3 -0
@@ -431,3 +431,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/sparc.in +3 -0
@@ -435,3 +435,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/sparc64.in +3 -0
@@ -398,3 +398,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
include/lapi/syscalls/x86_64.in +3 -0
@@ -380,3 +380,6 @@ removexattrat 466 open_tree_attr 467 file_getattr 468 file_setattr 469 +listns 470 +rseq_slice_yield 471 +fchroot 472
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] syscalls: add v7.3 syscall numbers
Hi Andrea,
Quoted 1 line · Andrea Cervesato
syscalls: add v7.3 syscall numbers
--- [PATCH 4/16] ---
Quoted 1 line
fchroot01: test
fchroot()with a directory fd
Could this subject be prefixed with [STAGING]? Linux 7.2 is the latest stable release, while this test targets fchroot() from Linux 7.3.
--- [PATCH 5/16] ---
Quoted 1 line
fchroot02: test
fchroot()invalid arguments
Could this subject be prefixed with [STAGING] because the tested syscall is not present in Linux 7.2?
--- [PATCH 6/16] ---
Quoted 1 line
fchroot03: test
fchroot()permission checks
Could this subject be prefixed with [STAGING] because the tested syscall is not present in Linux 7.2?
Quoted 1 line
* :manpage:
fchroot(2)was introduced in Linux v7.3.
Could the space be moved after the closing backtick? As written, it becomes part of the man-page role target.
--- [PATCH 7/16] ---
Quoted 1 line
fchroot04: test
fchroot()into failfs as root
Could this subject be prefixed with [STAGING] because fchroot() and failfs are not present in Linux 7.2?
--- [PATCH 8/16] ---
Quoted 1 line
fchroot05: test failfs root can not be referenced
Could this subject be prefixed with [STAGING] because fchroot() and failfs are not present in Linux 7.2?
--- [PATCH 9/16] ---
Quoted 1 line
fchroot06: test path walks under failfs root
Could this subject be prefixed with [STAGING] because fchroot() and failfs are not present in Linux 7.2?
Quoted 1 line
off += snprintf(upwards + off, sizeof(upwards) - off, "/..");
Could truncation be handled here? LTP accepts an arbitrary absolute TMPDIR. With a sufficiently deep path, off grows past sizeof(upwards), the size subtraction underflows, and the next iteration passes an out-of-bounds pointer and a huge size to snprintf().
--- [PATCH 10/16] ---
Quoted 1 line
fchroot07: test execve blocked by failfs root
Could this subject be prefixed with [STAGING] because fchroot() and failfs are not present in Linux 7.2?
--- [PATCH 11/16] ---
Quoted 1 line
fchroot08: test failfs root fork inheritance
Could this subject be prefixed with [STAGING] because fchroot() and failfs are not present in Linux 7.2?
--- [PATCH 12/16] ---
Quoted 1 line
fchroot09: test setns escape from failfs root
Could this subject be prefixed with [STAGING] because fchroot() and failfs are not present in Linux 7.2?
Quoted 4 lines
SAFE_STAT(tst_tmpdir_path(), &st); TST_EXP_EXPR(st.st_dev == realcwd.st_dev && st.st_ino == realcwd.st_ino, "working directory restored after setns()");
Could this stat "." and compare it with realroot instead? mntns_install() sets both fs->pwd and fs->root to the mount namespace root. Calling stat on an absolute tmpdir path succeeds regardless of the current working directory, so a regression that leaves pwd unchanged would pass this check.
--- [PATCH 13/16] ---
Quoted 1 line
fchroot10: test failfs entry without
no_new_privs
Could this subject be prefixed with [STAGING] because fchroot() and failfs are not present in Linux 7.2?
--- [PATCH 14/16] ---
Quoted 1 line
fchroot11: test failfs entry with
no_new_privs
Could this subject be prefixed with [STAGING] because fchroot() and failfs are not present in Linux 7.2?
--- [PATCH 15/16] ---
Quoted 1 line
fchroot12: test failfs entry with shared
fs_struct
Could this subject be prefixed with [STAGING] because fchroot() and failfs are not present in Linux 7.2?
--- [PATCH 16/16] ---
Quoted 1 line
fchroot13: test failfs entry when chrooted
Could this subject be prefixed with [STAGING] because fchroot() and failfs are not present in Linux 7.2?
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] syscalls: add v7.3 syscall numbers
Quoted 2 lines
Could this subject be prefixed with [STAGING]? Linux 7.2 is the latest stable release, while this test targets
fchroot()from Linux 7.3.
Please ignore this, it's handled by patchwork and there's no way to obtain it.
Quoted 4 lines
Quoted 1 line
* :manpage:
fchroot(2)was introduced in Linux v7.3.Could the space be moved after the closing backtick? As written, it becomes part of the man-page role target.
will fix before merge.
Quoted 6 lines
Quoted 1 line
off += snprintf(upwards + off, sizeof(upwards) - off, "/..");Could truncation be handled here? LTP accepts an arbitrary absolute TMPDIR. With a sufficiently deep path, off grows past sizeof(upwards), the size subtraction underflows, and the next iteration passes an out-of-bounds pointer and a huge size to
snprintf().
this can be fixed indeed.
Quoted 9 lines
Quoted 4 lines
SAFE_STAT(tst_tmpdir_path(), &st); TST_EXP_EXPR(st.st_dev == realcwd.st_dev && st.st_ino == realcwd.st_ino, "working directory restored after setns()");Could this stat "." and compare it with realroot instead?
mntns_install()sets bothfs->pwdandfs->rootto the mount namespace root. Calling stat on an absolute tmpdir path succeeds regardless of the current working directory, so a regression that leaves pwd unchanged would pass this check.
this is funny, it was "." before and it was complaining. I will use "." before merge.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 2/16 syscalls: update outdated syscall entries
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Add uprobe (336) on x86_64 and clone3 (435) on sparc, which were missing from the architecture syscall tables.
Drop the _sysctl and timerfd entries because both are wired to sys_ni_syscall in the kernel syscall tables and cannot be called.
--- include/lapi/syscalls/arm.in | 1 - include/lapi/syscalls/i386.in | 1 - include/lapi/syscalls/mips64.in | 2 -- include/lapi/syscalls/mips64n32.in | 2 -- include/lapi/syscalls/mipso32.in | 2 -- include/lapi/syscalls/parisc.in | 1 - include/lapi/syscalls/powerpc.in | 1 - include/lapi/syscalls/powerpc64.in | 1 - include/lapi/syscalls/s390.in | 2 -- include/lapi/syscalls/s390x.in | 2 -- include/lapi/syscalls/sh.in | 1 - include/lapi/syscalls/sparc.in | 2 +- include/lapi/syscalls/sparc64.in | 2 +- include/lapi/syscalls/x86_64.in | 2 +- 14 files changed, 3 insertions(+), 19 deletions(-)
include/lapi/syscalls/arm.in +0 -1
@@ -109,7 +109,6 @@ readv 145 writev 146 getsid 147 fdatasync 148 -_sysctl 149 mlock 150 munlock 151 mlockall 152
include/lapi/syscalls/i386.in +0 -1
@@ -145,7 +145,6 @@ readv 145 writev 146 getsid 147 fdatasync 148 -_sysctl 149 mlock 150 munlock 151 mlockall 152
include/lapi/syscalls/mips64.in +0 -2
@@ -150,7 +150,6 @@ mlockall 5148 munlockall 5149 vhangup 5150 pivot_root 5151 -_sysctl 5152 prctl 5153 adjtimex 5154 setrlimit 5155
@@ -272,7 +271,6 @@ ioprio_set 5273 ioprio_get 5274 utimensat 5275 signalfd 5276 -timerfd 5277 eventfd 5278 fallocate 5279 timerfd_create 5280
include/lapi/syscalls/mips64n32.in +0 -2
@@ -150,7 +150,6 @@ mlockall 6148 munlockall 6149 vhangup 6150 pivot_root 6151 -_sysctl 6152 prctl 6153 adjtimex 6154 setrlimit 6155
@@ -276,7 +275,6 @@ ioprio_set 6277 ioprio_get 6278 utimensat 6279 signalfd 6280 -timerfd 6281 eventfd 6282 fallocate 6283 timerfd_create 6284
include/lapi/syscalls/mipso32.in +0 -2
@@ -144,7 +144,6 @@ cachectl 4148 sysmips 4149 getsid 4151 fdatasync 4152 -_sysctl 4153 mlock 4154 munlock 4155 mlockall 4156
@@ -307,7 +306,6 @@ ioprio_set 4314 ioprio_get 4315 utimensat 4316 signalfd 4317 -timerfd 4318 eventfd 4319 fallocate 4320 timerfd_create 4321
include/lapi/syscalls/parisc.in +0 -1
@@ -142,7 +142,6 @@ readv 145 writev 146 getsid 147 fdatasync 148 -_sysctl 149 mlock 150 munlock 151 mlockall 152
include/lapi/syscalls/powerpc.in +0 -1
@@ -145,7 +145,6 @@ readv 145 writev 146 getsid 147 fdatasync 148 -_sysctl 149 mlock 150 munlock 151 mlockall 152
include/lapi/syscalls/powerpc64.in +0 -1
@@ -145,7 +145,6 @@ readv 145 writev 146 getsid 147 fdatasync 148 -_sysctl 149 mlock 150 munlock 151 mlockall 152
include/lapi/syscalls/s390.in +0 -2
@@ -126,7 +126,6 @@ readv 145 writev 146 getsid 147 fdatasync 148 -_sysctl 149 mlock 150 munlock 151 mlockall 152
@@ -291,7 +290,6 @@ utimes 313 fallocate 314 utimensat 315 signalfd 316 -timerfd 317 eventfd 318 timerfd_create 319 timerfd_settime 320
include/lapi/syscalls/s390x.in +0 -2
@@ -107,7 +107,6 @@ readv 145 writev 146 getsid 147 fdatasync 148 -_sysctl 149 mlock 150 munlock 151 mlockall 152
@@ -258,7 +257,6 @@ utimes 313 fallocate 314 utimensat 315 signalfd 316 -timerfd 317 eventfd 318 timerfd_create 319 timerfd_settime 320
include/lapi/syscalls/sh.in +0 -1
@@ -128,7 +128,6 @@ readv 145 writev 146 getsid 147 fdatasync 148 -_sysctl 149 mlock 150 munlock 151 mlockall 152
include/lapi/syscalls/sparc.in +1 -1
@@ -246,7 +246,6 @@ sched_get_priority_min 247 sched_rr_get_interval 248 nanosleep 249 mremap 250 -_sysctl 251 getsid 252 fdatasync 253 nfsservctl 254
@@ -402,6 +401,7 @@ fsconfig 431 fsmount 432 fspick 433 pidfd_open 434 +clone3 435 close_range 436 openat2 437 pidfd_getfd 438
include/lapi/syscalls/sparc64.in +1 -1
@@ -228,7 +228,6 @@ sched_get_priority_min 247 sched_rr_get_interval 248 nanosleep 249 mremap 250 -_sysctl 251 getsid 252 fdatasync 253 nfsservctl 254
@@ -365,6 +364,7 @@ fsconfig 431 fsmount 432 fspick 433 pidfd_open 434 +clone3 435 close_range 436 openat2 437 pidfd_getfd 438
include/lapi/syscalls/x86_64.in +1 -1
@@ -154,7 +154,6 @@ munlockall 152 vhangup 153 modify_ldt 154 pivot_root 155 -_sysctl 156 prctl 157 arch_prctl 158 adjtimex 159
@@ -334,6 +333,7 @@ statx 332 io_pgetevents 333 rseq 334 uretprobe 335 +uprobe 336 pidfd_send_signal 424 io_uring_setup 425 io_uring_enter 426
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 3/16 lapi: fallback fchroot() parameters
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Add to fcntl.h fallback definitions:
- FD_PIDFS_ROOT
- FD_NSFS_ROOT
- FD_FAILFS_ROOT
--- include/lapi/fcntl.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/lapi/fcntl.h +13 -0
@@ -144,6 +144,19 @@# endif #endif +/* Roots of kernel internal pseudo filesystems, usable as fd sentinels */ +#ifndef FD_PIDFS_ROOT +# define FD_PIDFS_ROOT -10002 +#endif + +#ifndef FD_NSFS_ROOT +# define FD_NSFS_ROOT -10003 +#endif + +#ifndef FD_FAILFS_ROOT +# define FD_FAILFS_ROOT -10004 +#endif +#ifndef FALLOC_FL_KEEP_SIZE # define FALLOC_FL_KEEP_SIZE 1#endif
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 4/16 fchroot01: test fchroot() with a directory fd
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that fchroot() with a directory fd moves the process root to the directory referenced by the fd.
fchroot() was introduced in Linux v7.3, so the test is added to the staging runtest file.
--- runtest/staging | 2 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/Makefile | 7 ++++ testcases/kernel/syscalls/fchroot/fchroot01.c | 59 +++++++++++++++++++++++++++ 4 files changed, 69 insertions(+)
runtest/staging +2 -0
@@ -1 +1,3 @@ # Tests for features that are not yet in the stable kernel ABI + +fchroot01 fchroot01
testcases/kernel/syscalls/fchroot/.gitignore new file +1 -0
@@ -0,0 +1 @@ +fchroot01
testcases/kernel/syscalls/fchroot/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2026 SUSE LLC Andrea Cervesato <[email protected]> + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fchroot/fchroot01.c new file +59 -0
59 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 04/16] fchroot01: test fchroot() with a directory fd
Hi!
Quoted 11 lines
+/*\
+ * Test that :manpage:fchroot(2)with a regular directory fd moves the
+ * process root to the directory referenced by the fd.
+ *
+ * This is the fd-based counterpart of :manpage:chroot(2), introduced in
+ * Linux v7.3. Root is required because :manpage:fchroot(2)with a regular
+ * directory fd requires ``CAP_SYS_CHROOT``.
+ *
+ * The syscall runs in a forked child so that the root of the parent
+ * process, which the test framework needs for its cleanup, is left
+ * untouched.
I do not think that we need this. The process that runs the run() function is forked from the library process in order for the test to be isolated from the library.
As long as we do not have a custom cleanup() function that needs to run outside of the jail we do not have to fork in the run().
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 04/16] fchroot01: test fchroot() with a directory fd
Hi Cyril,
Quoted 10 lines
Quoted 3 lines
+ * The syscall runs in a forked child so that the root of the parent
+ * process, which the test framework needs for its cleanup, is left
+ * untouched.I do not think that we need this. The process that runs the
run()function is forked from the library process in order for the test to be isolated from the library.As long as we do not have a custom
cleanup()function that needs to run outside of the jail we do not have to fork in therun().
the fork() ensures that if fchroot() passes (instead of failing) at the next iterations we don't have a dirty environment. This is done for all tests, so iterations always starts from scratch.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 04/16] fchroot01: test fchroot() with a directory fd
Hi!
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
+ * The syscall runs in a forked child so that the root of the parent
+ * process, which the test framework needs for its cleanup, is left
+ * untouched.I do not think that we need this. The process that runs the
run()function is forked from the library process in order for the test to be isolated from the library.
Quoted 6 lines
Quoted 2 lines
As long as we do not have a custom
cleanup()function that needs to run outside of the jail we do not have to fork in therun().the
fork()ensures that iffchroot()passes (instead of failing) at the next iterations we don't have a dirty environment. This is done for all tests, so iterations always starts from scratch.
Ah, right, that makes sense with -i 10. But then all the comments about library cleanup are wrong.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 5/16 fchroot02: test fchroot() invalid arguments
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify the fchroot() error paths: a non-zero flags argument fails with EINVAL before anything else, an invalid fd fails with EBADF, including the FD_PIDFS_ROOT and FD_NSFS_ROOT sentinels, and a fd referring to a regular file fails with ENOTDIR. All these checks happen before the CAP_SYS_CHROOT check, so no privileges are needed.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot02.c | 80 +++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)
runtest/staging +1 -0
@@ -1,3 +1,4 @@ # Tests for features that are not yet in the stable kernel ABI fchroot01 fchroot01 +fchroot02 fchroot02
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -1 +1,2 @@ fchroot01 +fchroot02
testcases/kernel/syscalls/fchroot/fchroot02.c new file +80 -0
80 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 05/16] fchroot02: test fchroot() invalid arguments
Hi!
Quoted 6 lines
+/*\
+ * Test the :manpage:fchroot(2)error paths for invalid arguments.
+ *
+ * :manpage:fchroot(2)was introduced in Linux v7.3. The syscall checks its
+ * arguments in this order:
+ *
Quoted 8 lines
+ * - a non-zero flags argument fails with ``EINVAL`` before anything else,
+ * including with the ``FD_FAILFS_ROOT`` sentinel and with an invalid fd
+ * - an invalid fd fails with ``EBADF``, including the ``FD_PIDFS_ROOT`` and
+ * ``FD_NSFS_ROOT`` sentinels which :manpage:fchroot(2)does not accept
+ * - a fd referring to a regular file fails with ``ENOTDIR``
+ *
+ * All these checks happen before the ``CAP_SYS_CHROOT`` check, so the test
+ * needs no privileges.
The order of check in kernel is never guaranteed and subject to change at any time. We shouldn't rely on particular check being done first.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 6/16 fchroot03: test fchroot() permission checks
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that with a regular directory fd the kernel first checks the execute permission on the directory and then CAP_SYS_CHROOT: an unprivileged process with an accessible directory fails with EPERM and a process without execute permission fails with EACCES.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot03.c | 78 +++++++++++++++++++++++++++ 3 files changed, 80 insertions(+)
runtest/staging +1 -0
@@ -2,3 +2,4 @@ fchroot01 fchroot01 fchroot02 fchroot02 +fchroot03 fchroot03
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -1,2 +1,3 @@ fchroot01 fchroot02 +fchroot03
testcases/kernel/syscalls/fchroot/fchroot03.c new file +78 -0
78 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 06/16] fchroot03: test fchroot() permission checks
Hi!
Quoted 4 lines
Verify that with a regular directory fd the kernel first checks the execute permission on the directory and then
CAP_SYS_CHROOT: an unprivileged process with an accessible directory fails with EPERM and a process without execute permission fails with EACCES.
Here as well, the order of the checks is subject to change.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 06/16] fchroot03: test fchroot() permission checks
Hi Cyril,
Quoted 7 lines
Hi!
Quoted 4 lines
Verify that with a regular directory fd the kernel first checks the execute permission on the directory and then
CAP_SYS_CHROOT: an unprivileged process with an accessible directory fails with EPERM and a process without execute permission fails with EACCES.Here as well, the order of the checks is subject to change.
sorry I don't get the review, can you please explain where is the issue? it's a description problem only?
same for the other reviews
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 06/16] fchroot03: test fchroot() permission checks
Hi!
Quoted 11 lines
Quoted 6 lines
Quoted 4 lines
Verify that with a regular directory fd the kernel first checks the execute permission on the directory and then
CAP_SYS_CHROOT: an unprivileged process with an accessible directory fails with EPERM and a process without execute permission fails with EACCES.Here as well, the order of the checks is subject to change.
sorry I don't get the review, can you please explain where is the issue? it's a description problem only?
same for the other reviews
The problem here is that the order in which kernel checks for CAP_SYS_ROOT or invalid fchroot() flags is not defined. It checks for CAP_SYS_ROOT last now, but that is not something we can take for granted.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 7/16 fchroot04: test fchroot() into failfs as root
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that entering failfs with the FD_FAILFS_ROOT sentinel succeeds with CAP_SYS_CHROOT and that every absolute path lookup then fails with EOPNOTSUPP, while the working directory is reported as unreachable by getcwd().
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot04.c | 70 +++++++++++++++++++++++++++ 3 files changed, 72 insertions(+)
runtest/staging +1 -0
@@ -3,3 +3,4 @@ fchroot01 fchroot01 fchroot02 fchroot02 fchroot03 fchroot03 +fchroot04 fchroot04
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -1,3 +1,4 @@ fchroot01 fchroot02 fchroot03 +fchroot04
testcases/kernel/syscalls/fchroot/fchroot04.c new file +70 -0
70 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 07/16] fchroot04: test fchroot() into failfs as root
Hi!
Quoted 10 lines
+/*\
+ * Test :manpage:fchroot(2)with the ``FD_FAILFS_ROOT`` sentinel as a
+ * privileged process.
+ *
+ * :manpage:fchroot(2)was introduced in Linux v7.3 together with failfs,
+ * a kernel internal filesystem where every operation fails with
+ * ``EOPNOTSUPP``. The ``FD_FAILFS_ROOT`` sentinel moves the process root
+ * there without needing a file descriptor: it is the ``fs_struct`` equivalent
+ * of ``RESOLVE_BENEATH``.
+ *
Quoted 8 lines
+ * The test verifies that entering failfs succeeds with ``CAP_SYS_CHROOT`` and
+ * that every absolute path lookup then fails with ``EOPNOTSUPP``. The working
+ * directory, left behind in the real filesystem, is consequently reported
+ * as unreachable by :manpage:getcwd(2).
+ *
+ * The syscall runs in a forked child because leaving failfs requires a
+ * mount namespace file descriptor and the parent needs its root for the
+ * test framework cleanup.
Here as well no need for the fork().
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 8/16 fchroot05: test failfs root can not be referenced
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that once fchroot() moved the root into failfs, the root directory can not be opened anymore, not even with O_PATH, nor pinned by following the /proc/self/root magic link, although readlink() still names it as "failfs:/" since it does not follow the link.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot05.c | 75 +++++++++++++++++++++++++++ 3 files changed, 77 insertions(+)
runtest/staging +1 -0
@@ -4,3 +4,4 @@ fchroot01 fchroot01 fchroot02 fchroot02 fchroot03 fchroot03 fchroot04 fchroot04 +fchroot05 fchroot05
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -2,3 +2,4 @@ fchroot01 fchroot02 fchroot03 fchroot04 +fchroot05
testcases/kernel/syscalls/fchroot/fchroot05.c new file +75 -0
75 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 08/16] fchroot05: test failfs root can not be referenced
Hi!
testcases/kernel/syscalls/fchroot/fchroot05.c line 37
Quoted 4 lines
testcases/kernel/syscalls/fchroot/fchroot05.c new file +4
-0+static void run (void ) +{ +if (SAFE_FORK ()) +return ;
Here as well, this shouldn't be needed.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 9/16 fchroot06: test path walks under failfs root
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that once the root is in failfs only lookups anchored at a file descriptor keep working: relative lookups from the working directory and from a pre-opened directory fd succeed, absolute symlinks fail with EOPNOTSUPP and ".." walks clamp at the top of the mount tree, landing on the real root.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot06.c | 117 ++++++++++++++++++++++++++ 3 files changed, 119 insertions(+)
runtest/staging +1 -0
@@ -5,3 +5,4 @@ fchroot02 fchroot02 fchroot03 fchroot03 fchroot04 fchroot04 fchroot05 fchroot05 +fchroot06 fchroot06
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -3,3 +3,4 @@ fchroot02 fchroot03 fchroot04 fchroot05 +fchroot06
testcases/kernel/syscalls/fchroot/fchroot06.c new file +117 -0
117 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 09/16] fchroot06: test path walks under failfs root
Hi!
Quoted 47 lines
testcases/kernel/syscalls/fchroot/fchroot06.c new file +47
-0+// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2026 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* Test path walks under the failfs root. +* +* Once :manpage:`fchroot(2)` moved the process root into failfs, only +* lookups anchored at a file descriptor keep working: +* +* - lookups relative to the working directory, which stays in the real +* filesystem, keep working +* - lookups anchored at a pre-opened directory fd keep working, including +* resolution of relative symlinks +* - absolute symlinks restart the walk at the failfs root and fail with +* ``EOPNOTSUPP`` +* - ".." walks clamp at the top of the mount tree, not at the failfs +* root, so walking up from the working directory lands on the real +* root +* +* Root is required because entering failfs with the ``FD_FAILFS_ROOT`` +* sentinel requires ``CAP_SYS_CHROOT``. +* +* The test runs in a forked child so the root of the parent process is +* left untouched. +*/ + +#define _GNU_SOURCE +#include <fcntl.h> +#include <sys/stat.h> +#include "tst_test.h" +#include "lapi/fcntl.h" +#include "lapi/syscalls.h" +#include "tst_safe_file_at.h" + +#define RELDIR "rel" +#define ABSDIR "abs" + +static char upwards[PATH_MAX ]; + +static void run (void ) +{ +if (SAFE_FORK ()) +return ; + +struct stat realroot, st;
testcases/kernel/syscalls/fchroot/fchroot06.c line 57
Quoted 10 lines
testcases/kernel/syscalls/fchroot/fchroot06.c new file +10
-0+int dfd, fd; + +SAFE_STAT ("/" , &realroot); + dfd =SAFE_OPEN ("." ,O_RDONLY |O_DIRECTORY ); + +TST_EXP_PASS (tst_syscall (__NR_fchroot,FD_FAILFS_ROOT ,0 ), +"fchroot() with the FD_FAILFS_ROOT sentinel" ); + + fd =SAFE_OPENAT (AT_FDCWD ,"." ,O_RDONLY |O_DIRECTORY ); +SAFE_CLOSE (fd);
This is a test right? So it should be TST_EXP_FD(openat(...));
testcases/kernel/syscalls/fchroot/fchroot06.c line 64
Quoted 6 lines
testcases/kernel/syscalls/fchroot/fchroot06.c new file +6
-0+ fd =SAFE_OPENAT (dfd,"canary" ,O_WRONLY |O_CREAT ,0600 ); +SAFE_WRITE (SAFE_WRITE_ALL , fd,"x" ,1 ); +SAFE_CLOSE (fd); + + fd =SAFE_OPENAT (dfd,RELDIR ,O_RDONLY ); +SAFE_CLOSE (fd);
These as well.
testcases/kernel/syscalls/fchroot/fchroot06.c line 71
Quoted 6 lines
testcases/kernel/syscalls/fchroot/fchroot06.c new file +6
-0+TST_EXP_FAIL2 (openat (dfd,ABSDIR ,O_RDONLY ),EOPNOTSUPP , +"resolution of an absolute symlink" ); + + fd =SAFE_OPENAT (AT_FDCWD , upwards,O_PATH ); +SAFE_FSTAT (fd, &st); +SAFE_CLOSE (fd);
And here.
Quoted 52 lines
testcases/kernel/syscalls/fchroot/fchroot06.c new file +45
-0+TST_EXP_EXPR (st.st_dev == realroot.st_dev && + st.st_ino == realroot.st_ino, +"'..' walk clamps at the top of the mount tree" ); + +SAFE_CLOSE (dfd); + +exit (0 ); +} + +static void setup (void ) +{ +char *tmpdir; +char abs_path[PATH_MAX ]; +struct stat root_st, st; +int fd, off; + + tmpdir =tst_tmpdir_path (); +snprintf (abs_path,sizeof (abs_path),"%s/%s" , tmpdir,"target" ); + +SAFE_TOUCH ("target" ,0644 ,NULL ); +SAFE_SYMLINK ("target" ,RELDIR ); +SAFE_SYMLINK (abs_path,ABSDIR ); + +SAFE_STAT ("/" , &root_st); + + off =snprintf (upwards,sizeof (upwards),".." ); +while (1 ) { + fd =SAFE_OPENAT (AT_FDCWD , upwards,O_PATH ); +SAFE_FSTAT (fd, &st); +SAFE_CLOSE (fd); + +if (st.st_dev == root_st.st_dev && st.st_ino == root_st.st_ino) +break ; + + off +=snprintf (upwards + off,sizeof (upwards) - off,"/.." ); + } +} + +static struct tst_test test = { + .setup = setup, + .test_all = run, + .needs_root =1 , + .needs_tmpdir =1 , + .forks_child =1 , +};Signature · 6 lines
-- 2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 10/16 fchroot07: test execve blocked by failfs root
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that after fchroot() moved the root into failfs, loading a binary by absolute path fails with EOPNOTSUPP. The exec runs in a grandchild so a wrongly successful exec is still detected through the exit code.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot07.c | 72 +++++++++++++++++++++++++++ 3 files changed, 74 insertions(+)
runtest/staging +1 -0
@@ -6,3 +6,4 @@ fchroot03 fchroot03 fchroot04 fchroot04 fchroot05 fchroot05 fchroot06 fchroot06 +fchroot07 fchroot07
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -4,3 +4,4 @@ fchroot03 fchroot04 fchroot05 fchroot06 +fchroot07
testcases/kernel/syscalls/fchroot/fchroot07.c new file +72 -0
72 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH STAGING v2 10/16] fchroot07: test execve blocked by failfs root
Hi!
Quoted 89 lines
Verify that after
fchroot()moved the root into failfs, loading a binary by absolute path fails with EOPNOTSUPP. The exec runs in a grandchild so a wrongly successful exec is still detected through the exit code.Signed-off-by Andrea Cervesato <[email protected]>--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot07.c | 72 +++++++++++++++++++++++++++ 3 files changed, 74 insertions(+)runtest/staging +1
-0@@ -6,3 +6,4 @@ fchroot03 fchroot03 fchroot04 fchroot04 fchroot05 fchroot05 fchroot06 fchroot06 +fchroot07 fchroot07testcases/kernel/syscalls/fchroot/.gitignore +1
-0@@ -4,3 +4,4 @@ fchroot03 fchroot04 fchroot05 fchroot06 +fchroot07testcases/kernel/syscalls/fchroot/fchroot07.c new file +53
-0@@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2026 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* Test that :manpage:`execve(2)` is blocked under the failfs root. +* +* After :manpage:`fchroot(2)` moved the process root into failfs, loading +* a binary by absolute path fails with ``EOPNOTSUPP``. +* +* Root is required because entering failfs with the ``FD_FAILFS_ROOT`` +* sentinel requires ``CAP_SYS_CHROOT``. +* +* The exec runs in a grandchild: a wrongly successful exec would replace +* the test image, so the outcome can only be reported when the exec call +* returns, and the grandchild exit code tells the parent whether the +* image was replaced. +*/ + +#define _GNU_SOURCE +#include <sys/wait.h> +#include <unistd.h> +#include "tst_test.h" +#include "lapi/fcntl.h" +#include "lapi/syscalls.h" + +/* Marker exit code proving the grandchild image was not replaced. */ +#define EXEC_NOT_REPLACED 42 + +static void check_exec_blocked (void ) +{ +pid_t pid =SAFE_FORK (); +int status; + +if (!pid) { +TST_EXP_FAIL (execl ("/bin/true" ,"true" ,NULL ),EOPNOTSUPP , +"absolute exec blocked by the failfs root" ); +exit (EXEC_NOT_REPLACED ); + } + +SAFE_WAITPID (pid, &status,0 ); +if (!WIFEXITED (status) ||WEXITSTATUS (status) !=EXEC_NOT_REPLACED ) +tst_res (TFAIL ,"exec replaced the test image" ); +} + +static void run (void ) +{ +if (SAFE_FORK ()) +return ; + +TST_EXP_PASS (tst_syscall (__NR_fchroot,FD_FAILFS_ROOT ,0 ), +"fchroot() with the FD_FAILFS_ROOT sentinel" );
testcases/kernel/syscalls/fchroot/fchroot07.c line 63
Quoted 10 lines
testcases/kernel/syscalls/fchroot/fchroot07.c new file +10
-0+ +check_exec_blocked (); + +exit (0 ); +} + +static void setup (void ) +{ +if (access ("/bin/true" ,X_OK )) +tst_brk (TCONF |TERRNO ,"/bin/true is not available" );
I wonder if it would be better to add a fchroot07_child.c, it could do just tst_reinit() and tst_res(TFAIL, "child executed") and we can then drop the WAITPID and WIFEXITED() checks from here...
Quoted 15 lines
testcases/kernel/syscalls/fchroot/fchroot07.c new file +8
-0+} + +static struct tst_test test = { + .setup = setup, + .test_all = run, + .needs_root =1 , + .forks_child =1 , +};Signature · 6 lines
-- 2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 11/16 fchroot08: test failfs root fork inheritance
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that the root moved into failfs by fchroot() lives in the fs_struct which is duplicated on fork, so a child of a process with the failfs root also fails every absolute path lookup with EOPNOTSUPP.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot08.c | 69 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+)
runtest/staging +1 -0
@@ -7,3 +7,4 @@ fchroot04 fchroot04 fchroot05 fchroot05 fchroot06 fchroot06 fchroot07 fchroot07 +fchroot08 fchroot08
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -5,3 +5,4 @@ fchroot04 fchroot05 fchroot06 fchroot07 +fchroot08
testcases/kernel/syscalls/fchroot/fchroot08.c new file +69 -0
69 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 12/16 fchroot09: test setns escape from failfs root
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that entering failfs with fchroot() is hard to undo: a process inside counts as chrooted, so the remaining way out is a pre-opened mount namespace fd. setns() into it resets both the root and the working directory.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot09.c | 87 +++++++++++++++++++++++++++ 3 files changed, 89 insertions(+)
runtest/staging +1 -0
@@ -8,3 +8,4 @@ fchroot05 fchroot05 fchroot06 fchroot06 fchroot07 fchroot07 fchroot08 fchroot08 +fchroot09 fchroot09
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -6,3 +6,4 @@ fchroot05 fchroot06 fchroot07 fchroot08 +fchroot09
testcases/kernel/syscalls/fchroot/fchroot09.c new file +87 -0
87 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 13/16 fchroot10: test failfs entry without no_new_privs
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that unprivileged fchroot() into failfs is refused withoutno_new_privs: without it a setuid binary on a regular mount is still reachable via an inherited directory fd, and executing it with an unusable root directory is the classic confused deputy, so the kernel refuses the syscall with EPERM.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot10.c | 50 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+)
runtest/staging +1 -0
@@ -9,3 +9,4 @@ fchroot06 fchroot06 fchroot07 fchroot07 fchroot08 fchroot08 fchroot09 fchroot09 +fchroot10 fchroot10
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -7,3 +7,4 @@ fchroot06 fchroot07 fchroot08 fchroot09 +fchroot10
testcases/kernel/syscalls/fchroot/fchroot10.c new file +50 -0
50 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 14/16 fchroot11: test failfs entry with no_new_privs
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that an unprivileged process may enter failfs when it committed to no_new_privs, since setuid binaries then pose no confused deputy risk anymore. The test also verifies that a process which entered failfs counts as chrooted: it can no longer create a user namespace with unshare() to regain CAP_SYS_CHROOT.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot11.c | 70 +++++++++++++++++++++++++++ 3 files changed, 72 insertions(+)
runtest/staging +1 -0
@@ -10,3 +10,4 @@ fchroot07 fchroot07 fchroot08 fchroot08 fchroot09 fchroot09 fchroot10 fchroot10 +fchroot11 fchroot11
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -8,3 +8,4 @@ fchroot07 fchroot08 fchroot09 fchroot10 +fchroot11
testcases/kernel/syscalls/fchroot/fchroot11.c new file +70 -0
70 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 15/16 fchroot12: test failfs entry with shared fs_struct
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that unprivileged fchroot() into failfs is refused with a shared fs_struct: a CLONE_FS sibling without no_new_privs could execute a setuid binary with the failfs root, so entry requires fs->users == 1, the same restriction setns() applies for the mount namespace. The sibling bumps fs->users to 2, making the syscall fail with EINVAL.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot12.c | 85 +++++++++++++++++++++++++++ 3 files changed, 87 insertions(+)
runtest/staging +1 -0
@@ -11,3 +11,4 @@ fchroot08 fchroot08 fchroot09 fchroot09 fchroot10 fchroot10 fchroot11 fchroot11 +fchroot12 fchroot12
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -9,3 +9,4 @@ fchroot08 fchroot09 fchroot10 fchroot11 +fchroot12
testcases/kernel/syscalls/fchroot/fchroot12.c new file +85 -0
85 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 16/16 fchroot13: test failfs entry when chrooted
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Verify that unprivileged fchroot() into failfs is refused when the process is already chrooted: moving the root of a chrooted task into failfs would allow it to escape its chroot via openat(fd, "..") with a pre-opened directory fd, so the kernel refuses the syscall with EPERM.
--- runtest/staging | 1 + testcases/kernel/syscalls/fchroot/.gitignore | 1 + testcases/kernel/syscalls/fchroot/fchroot13.c | 63 +++++++++++++++++++++++++++ 3 files changed, 65 insertions(+)
runtest/staging +1 -0
@@ -12,3 +12,4 @@ fchroot09 fchroot09 fchroot10 fchroot10 fchroot11 fchroot11 fchroot12 fchroot12 +fchroot13 fchroot13
testcases/kernel/syscalls/fchroot/.gitignore +1 -0
@@ -10,3 +10,4 @@ fchroot09 fchroot10 fchroot11 fchroot12 +fchroot13
testcases/kernel/syscalls/fchroot/fchroot13.c new file +63 -0
63 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp