Skip to content

fchroot: add fchroot() testing suite

Andrea Cervesato ltp 5 versions – Applied

Status from this message: Merged, Thanks!

Get series with b4
b4 am [email protected] change-id 20260819-fchroot-66115fd0d497

Versions newest first

  1. v5 Latest14 patches 9 repliesApplied
  2. v416 patches 13 repliesSuperseded
  3. v315 patches 1 replySuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v216 patches13 repliesSuperseded
v116 patches2 repliesSuperseded

Changes in v5 from the cover letter

- drop syscall table commits already merged in master
- drop [STAGING] prefix and move runtest entries to runtest/syscalls
- remove redundant exit(0) in forked test processes
- fchroot04, fchroot11: use /dev/zero instead of /etc/passwd
- fchroot06: simplify upwards path construction and use SAFE_STAT()
- fchroot08, fchroot09: drop unnecessary symlink setup and open "/" directly
- fchroot09: clarify setns() escape description
- fchroot11: check unprivileged userns support before testing failfs block
- Link to v4: https://lore.kernel.org/[email protected]

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/14lapi: fallback fchroot() parametersinclude/lapi/fcntl.h+13 -03 replies
2/14fchroot01: test fchroot() with a directory fdruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/Makefile +1 more+66 -00 replies
3/14fchroot02: test fchroot() invalid argumentsruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot02.c+77 -00 replies
4/14fchroot03: test fchroot() permission checksruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot03.c+72 -00 replies
5/14fchroot04: test fchroot() into failfs as rootruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot04.c+69 -00 replies
6/14fchroot05: test failfs root can not be referencedruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot05.c+75 -00 replies
7/14fchroot06: test path walks under failfs rootruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot06.c+126 -01 reply
8/14fchroot07: test execve blocked by failfs rootruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot07.c +1 more+77 -00 replies
9/14fchroot08: test failfs root fork inheritanceruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot08.c+54 -01 reply
10/14fchroot09: test setns escape from failfs rootruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot09.c+70 -01 reply
11/14fchroot10: test failfs entry without no_new_privsruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot10.c+54 -00 replies
12/14fchroot11: test failfs entry with no_new_privsruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot11.c+87 -01 reply
13/14fchroot12: test failfs entry with shared fs_structruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot12.c+85 -00 replies
14/14fchroot13: test failfs entry when chrootedruntest/syscalls testcases/kernel/syscalls/fchroot/.gitignore testcases/kernel/syscalls/fchroot/fchroot13.c+63 -01 reply

Reviews trailers per patch

All 14 patches have a Reviewed-by or Acked-by.

PatchCyril Hrubis
1/14R-b
2/14R-b
3/14R-b
4/14R-b
5/14R-b
6/14R-b
7/14R-b
8/14R-b
9/14R-b
10/14R-b
11/14R-b
12/14R-b
13/14R-b
14/14R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [LTP] [PATCH v5 00/14] fchroot: add fchroot() testing suite

fchroot() is a new syscall introduced in Linux v7.3 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 adds lapi fallback definitions for the new fd sentinels and 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

The testing suite creation has been assisted by GLM 5.3.

---
Changes in v5:
- drop syscall table commits already merged in master
- drop [STAGING] prefix and move runtest entries to runtest/syscalls
- remove redundant exit(0) in forked test processes
- fchroot04, fchroot11: use /dev/zero instead of /etc/passwd
- fchroot06: simplify upwards path construction and use SAFE_STAT()
- fchroot08, fchroot09: drop unnecessary symlink setup and open "/" directly
- fchroot09: clarify setns() escape description
- fchroot11: check unprivileged userns support before testing failfs block
- Link to v4: https://lore.kernel.org/[email protected]

Changes in v4:
- restore fchroot08 commit
- fix descriptions
- improve setup() inside tests
- Link to v3: https://lore.kernel.org/[email protected]

Changes in v3:
- remove order specific tests inside the descriptions
- fchroot07: add child
- fix snprintf() possible overflows
- fix tests using TST_EXP_* macros
- use stat(".", ..) where it's needed
- Link to v2: https://lore.kernel.org/[email protected]

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 (14):
lapi: fallback fchroot() parameters
fchroot01: test fchroot() with a directory fd
fchroot02: test fchroot() invalid arguments
fchroot03: test fchroot() permission checks
fchroot04: test fchroot() into failfs as root
fchroot05: test failfs root can not be referenced
fchroot06: test path walks under failfs root
fchroot07: test execve blocked by failfs root
fchroot08: test failfs root fork inheritance
fchroot09: test setns escape from failfs root
fchroot10: test failfs entry without no_new_privs
fchroot11: test failfs entry with no_new_privs
fchroot12: test failfs entry with shared fs_struct
fchroot13: test failfs entry when chrooted

 include/lapi/fcntl.h                               |  13 +++
 runtest/syscalls                                   |  14 +++
 testcases/kernel/syscalls/fchroot/.gitignore       |  14 +++
 testcases/kernel/syscalls/fchroot/Makefile         |   7 ++
 testcases/kernel/syscalls/fchroot/fchroot01.c      |  56 ++++++++++
 testcases/kernel/syscalls/fchroot/fchroot02.c      |  75 +++++++++++++
 testcases/kernel/syscalls/fchroot/fchroot03.c      |  70 ++++++++++++
 testcases/kernel/syscalls/fchroot/fchroot04.c      |  67 +++++++++++
 testcases/kernel/syscalls/fchroot/fchroot05.c      |  73 ++++++++++++
 testcases/kernel/syscalls/fchroot/fchroot06.c      | 124 +++++++++++++++++++++
 testcases/kernel/syscalls/fchroot/fchroot07.c      |  58 ++++++++++
 .../kernel/syscalls/fchroot/fchroot07_child.c      |  16 +++
 testcases/kernel/syscalls/fchroot/fchroot08.c      |  52 +++++++++
 testcases/kernel/syscalls/fchroot/fchroot09.c      |  68 +++++++++++
 testcases/kernel/syscalls/fchroot/fchroot10.c      |  52 +++++++++
 testcases/kernel/syscalls/fchroot/fchroot11.c      |  85 ++++++++++++++
 testcases/kernel/syscalls/fchroot/fchroot12.c      |  83 ++++++++++++++
 testcases/kernel/syscalls/fchroot/fchroot13.c      |  61 ++++++++++
 18 files changed, 988 insertions(+)

---
base-commit: 1aae0e4d9d1e2e7818fda773b372cee8fb856de7
change-id: 20260819-fchroot-66115fd0d497

Best regards,

Signature · 5 lines
Andrea Cervesato <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp