HomeFreeBSD

chroot: Improve error message for unprivileged use

Description

chroot: Improve error message for unprivileged use

When the security.bsd.unprivileged_chroot sysctl is set, chroot(2) can
be used by unprivileged users as long as the PROC_NO_NEW_PRIVS_CTL
process control is set.

chroot(8) has a -n command line flag to set this process control.
Add an explicit error for EPERM from chroot(2) if the -n flag is
necessary, but not present.

Before:

$ chroot / /bin/sh
chroot: /: Operation not permitted

After:

$ chroot / /bin/sh
chroot: unprivileged use requires -n

Reviewed by: kevans
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D51687

Details

Provenance
emasteAuthored on Aug 1 2025, 7:53 PM
Reviewer
kevans
Differential Revision
D51687: chroot: Improve error message for unprivileged use
Parents
rG095f6305772b: vm_pageout: Scan inactive dirty pages less aggressively
Branches
Unknown
Tags
Unknown