Page MenuHomeFreeBSD

bhyveload: use a dirfd to support -h
ClosedPublic

Authored by kevans on Jan 2 2024, 11:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 10 2024, 11:40 AM
Unknown Object (File)
May 10 2024, 2:00 AM
Unknown Object (File)
May 9 2024, 5:41 AM
Unknown Object (File)
May 6 2024, 7:24 AM
Unknown Object (File)
Apr 22 2024, 12:18 AM
Unknown Object (File)
Apr 22 2024, 12:18 AM
Unknown Object (File)
Apr 22 2024, 12:17 AM
Unknown Object (File)
Apr 22 2024, 12:17 AM

Details

Summary

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.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

allanjude added a subscriber: allanjude.

reviewed-by: allanjude

This revision is now accepted and ready to land.Jan 2 2024, 11:29 PM

Looks good, just a couple of nits.

usr.sbin/bhyveload/bhyveload.c
205

Why not handle the error properly? fdopendir() could fail due to a malloc() failure, and we do try to handle that above.

783

Since the function is called hostbase_open(), it'd be a bit more logical to handle all of this there. Currently the function just opens a file, there is nothing specific to "hostbase" about it.

usr.sbin/bhyveload/bhyveload.c
205

Whoops- I had only glanced at the manpage and noted that the only possible errors were EBADF and ENOTDIR, it didn't occur to me that it naturally does need to allocate some memory.

kevans marked 2 inline comments as done.

Address review feedback

This revision now requires review to proceed.Jan 3 2024, 6:03 PM
This revision is now accepted and ready to land.Jan 3 2024, 9:38 PM
This revision was automatically updated to reflect the committed changes.