This patch gives bhyve the ability to run inside a jailed environment. It introduces two new allow.* flags: allow.vmm and allow.novmm, with the default being allow.novmm.
Sponsored-by: HardenedBSD
Sponsored-by: G2, Inc
Differential D16057
Support bhyve within a jail lattera-gmail.com on Jun 29 2018, 1:09 AM. Authored by Tags Referenced Files
Details This patch gives bhyve the ability to run inside a jailed environment. It introduces two new allow.* flags: allow.vmm and allow.novmm, with the default being allow.novmm. Sponsored-by: HardenedBSD
Diff Detail
Event TimelineComment Actions Whoops. I just realized this version of the patch is based off of HardenedBSD's src tree. I'll update it soon based on FreeBSD's. Comment Actions @lattera-gmail.com first of all thanks for the patch. I'm curious to know what guest OS have you tested inside a jail, could you please share it with me? Also let me know what devices you used, as an example: virtio-blk, virtio-net and etc.. If you can share your tests, it would be perfect. Thanks. Comment Actions I had a pre-installed Kali Linux VM. I used vmrun.sh to run the VM in UEFI mode: sh /usr/share/examples/bhyve/vmrun.sh -c 4 -m 16g -t tap4 -C /dev/nmdm-kali-01-A -d /dev/zvol/rpool/bhyve/kali-01/disk-01 -E -P 5901 kali-01 My jail.conf(5) had an entry for the bhyve-01 jail: bhyve-01 { $epair = "epair6"; devfs_ruleset = 25; persist; vnet; allow.vmm; } My devfs.rules(5) file: [devfs_rules_bhyve_jail=25] add include $devfsrules_jail add path vmm unhide add path vmm/* unhide add path tap* unhide add path zvol/rpool/bhyve/* unhide add path nmdm* unhide
Comment Actions In addition to the question of where to check the permissions, there's also the issue that the allow.vmm parameter shouldn't exist in a non-VMM system. This means the SYSCTL_JAIL_PARAM should be defined in vmm_dev.c or some other vmm-related file; that way, if VMM is loaded as a module, the parameter would be attached to that module. For an example of module-specific parameters, see compat/linux/linux_mib.c (and where the setup is called in linux_common.c). This is for the parameters linux.*, so it's not quite the same. But there's no actual requirement that your parameter be top-level, and could still be allow.vmm. The problem is there's more code required for this than should be necessary for a simple allow bit. You don't need everything that linux_mib has, but you would need something to set up the parameter on module load. While I don't have support for dynamic allow.* parameters, I do have prison_add_vfs() in kern_jail.c, which is mostly for adding allow.mount.fsname parameters. I should change that a bit to allow for a more generic method of adding an allow.* flag. That would mean you have a dependency on me.
Comment Actions I agree in principle. However, the way the allow.* parameters work is different than adding independent parameters. In this case, I'd rather keep using the allow.* namespace, rather than adding a whole new jail param namespace (ie, vmm.allow). Re-using the allow.* namespace allows us to piggy-back on the pr_allow field in the prison structure. Adding a new namespace adds unnecessary complexity. If we were to add a generic and dynamic allow.* capability, that would be outside the scope of this patch. But, doing so would drastically reduce the complexity my implementation of your suggestion above. Before I come to a final decision, let's discuss this more. I'm open to ideas. I'm just unsure the time involved in adding such complexity just to dynamically hide/show allow.vmm is worth it.
Comment Actions I've added D16146, which makes a new allow.* bit easy: flag = prison_add_allow(NULL, "foo", NULL, "Jailed user may do the foo thing");
Comment Actions One more thing to do: jail(8) should mention the flag. There's a section about module-specific flags where I think it would fit better than the main allow.* section. Comment Actions Good call. I'll add that to the jail(8) manpage.
|