]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
jail(8): reset to root cpuset before attaching to run commands
authorKyle Evans <kevans@FreeBSD.org>
Thu, 4 Mar 2021 19:28:53 +0000 (13:28 -0600)
committerKyle Evans <kevans@FreeBSD.org>
Thu, 11 Mar 2021 19:24:28 +0000 (13:24 -0600)
commit7a1f6858dabfdb24d9f58a52fd5e6e1fe0ceead1
treeae6e75975e72459eae93759bdaf679ede108c11b
parent2b1bcf70b4d1a8ef62415cbb89890f08ae57a447
jail(8): reset to root cpuset before attaching to run commands

Recent changes have made it such that attaching to a jail will augment
the attaching process' cpu mask with the jail's cpuset. While this is
convenient for allowing the administrator to cpuset arbitrary programs
that will attach to a jail, this is decidedly not convenient for
executing long-running daemons during jail creation.

This change inserts a reset of the process cpuset to the root cpuset
between the fork and attach to execute a command. This allows commands
executed to have the widest mask possible, and the administrator can
cpuset(1) it back down inside the jail as needed.

With this applied, one should be able to change a jail's cpuset at
exec.poststart in addition to exec.created.  The former was made
difficult if jail(8) itself was running with a constrained set, as then
some processes may have been spawned inside the jail with a non-root
set.  The latter is the preferred option so that processes starting in
the jail are constrained appropriately up front.

Note that all system commands are still run with the process' initial
cpuset applied.

PR: 253724
Approved by: re (gjb)

(cherry picked from commit 466df976babed65f8a8de9e36d7f016a444609af)
(cherry picked from commit bdd61b6914f1f961b5f414b2d5cc623a5a829b89)
usr.sbin/jail/command.c