Page MenuHomeFreeBSD

bhyveload: validate character disk devices
Needs ReviewPublic

Authored by novel on Fri, Aug 28, 6:04 PM.

Details

Reviewers
None
Group Reviewers
bhyve
Summary

Currently, bhyveload(8) does not validate the supplied disk
image path. For example, it allows passing the /dev/null
device, which later fails in userboot because it does not
support DIOCGSECTORSIZE and DIOCGMEDIASIZE ioctls (see
userdisk_init() in stand/userboot/userboot/userboot_disk.c).

Fix that by checking DIOCGSECTORSIZE and DIOCGMEDIASIZE ioctls early.
A similar check already exists in bhyve(8).

Test Plan

Unpatched:

# bhyveload -m 2048 -d /dev/null test
Consoles: userboot  

FreeBSD/amd64 User boot lua, Revision 3.0
(Thu Aug 27 10:40:55 UTC 2026 root@freebsd14)
Bus error
#

Patched:

# bhyveload -m 2048 -d /dev/null test
bhyveload: Could not open '/dev/null': Inappropriate ioctl for device
# echo $?
64
#

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76280
Build 73163: arc lint + arc unit