]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
bhyveload: use a dirfd to support -h
authorKyle Evans <kevans@FreeBSD.org>
Wed, 3 Jan 2024 22:17:59 +0000 (16:17 -0600)
committerGordon Tetlow <gordon@FreeBSD.org>
Wed, 14 Feb 2024 05:43:15 +0000 (21:43 -0800)
commit48598b1670ce542419420f969d5a5bd47167eb17
treefa2416441b6584992761dd338414df53a33476d3
parent154dedade4654516dfd3737ae56d5b3e3721029a
bhyveload: use a dirfd to support -h

Don't allow lookups from the loader scripts, which in rare cases may be
in guest control depending on the setup, to leave the specified host
root.  Open the root dir and strictly do RESOLVE_BENEATH lookups from
there.

cb_open() has been restructured a bit to work nicely with this, using
fdopendir() in the directory case and just using the fd we already
opened in the regular file case.

hostbase_open() was split out to provide an obvious place to apply
rights(4) if that's something we care to do.

Reviewed by: allanjude (earlier version), markj
Approved by: so
Security: FreeBSD-SA-24:01.bhyveload
Security: CVE-2024-25940

(cherry picked from commit 6779d44bd878e3cf4723f7386b11da6508ab5431)
(cherry picked from commit 78345dbd7a004e0a6d1b717e7dbc758ae67ca293)
usr.sbin/bhyveload/bhyveload.c