[LTP] [PATCH STAGING v2 05/16] fchroot02: test fchroot() invalid arguments

Cyril Hrubis chrubis@suse.cz
Thu Aug 20 16:10:52 CEST 2026


Hi!
> +/*\
> + * 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:
> + *
> + * - 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.


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list