]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests/filesystems: add failfs selftests
authorChristian Brauner <brauner@kernel.org>
Fri, 24 Jul 2026 13:41:22 +0000 (15:41 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 27 Jul 2026 15:18:00 +0000 (17:18 +0200)
commitdf4b2889ea9a1ef809bfb7e1401e2cdc475956c8
tree70e2debc547695f7c681b3eef645b596b685a144
parent79d27fd718545db4731691e0a77e51d27dc1a41e
selftests/filesystems: add failfs selftests

Test the failfs semantics and both new entry points:

- fchdir(FD_FAILFS_ROOT):

  * working directory lookups and getcwd() fail
  * other sentinels are rejected
  * the state is recoverable while the root is untouched

- fchroot() with regular fds:
  * chroot parity
  * CAP_SYS_CHROOT required
  * ENOTDIR/EBADF/EINVAL checks

- fchroot(FD_FAILFS_ROOT):

  * absolute lookups, stat, statfs and opens of the root including O_PATH fail with EOPNOTSUPP
  * dirfd-anchored I/O keeps working
  * ".." walks clamp at the top of the mount tree
  * /proc magic links resolve but can't be stat through
  * absolute symlinks fail while relative symlinks keep resolving

- Unprivileged entry requires no_new_privs and is rejected for
  chrooted callers and for a shared fs_struct

- entering makes the task count as chrooted so user namespace creation
  fails

- Nothing can be mounted on top of failfs and OPEN_TREE_CLONE is
  rejected; the overmount test runs in a private mount namespace so a
  regression cannot touch the host root

- setns() to a kept mount namespace fd restores root and working
  directory

- The failfs root is inherited across fork() and absolute exec fails

- Exec by fd of a dynamically linked binary fails on opening its
  absolute PT_INTERP interpreter

The exec tests run the exec in a child so a wrongly successful exec
cannot replace the test image and masquerade as a pass.

Link: https://patch.msgid.link/20260724-work-failfs-v2-6-485dabbae185@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
tools/testing/selftests/Makefile
tools/testing/selftests/filesystems/failfs/.gitignore [new file with mode: 0644]
tools/testing/selftests/filesystems/failfs/Makefile [new file with mode: 0644]
tools/testing/selftests/filesystems/failfs/failfs_test.c [new file with mode: 0644]