Page MenuHomeFreeBSD

vmm: Consolidate VM name length checking
ClosedPublic

Authored by markj on Oct 28 2025, 8:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 13 2025, 7:36 PM
Unknown Object (File)
Nov 12 2025, 12:18 AM
Unknown Object (File)
Nov 11 2025, 5:50 PM
Unknown Object (File)
Nov 8 2025, 3:41 AM
Unknown Object (File)
Nov 5 2025, 3:00 AM
Unknown Object (File)
Oct 31 2025, 9:44 PM
Unknown Object (File)
Oct 31 2025, 5:18 PM
Unknown Object (File)
Oct 31 2025, 5:18 PM

Details

Summary

vm_create() is only called from one place. Rather than having similar
checks everywhere, move them to vmmdev_create().

We can safely assume that the name is nul-terminated, the vmmctl ioctl
handler at the legacy sysctl handler ensure this. So, don't bother with
strnlen().

Finally, make sure that the name buffers are the same size on all
platforms. VM_MAX_NAMELEN is supposed to be the maximum, not including
the nul terminator.

Diff Detail

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

Event Timeline

RISC-V is using a different value for VM_MAX_NAMELEN and should probably be fixed to match arm64/amd64. Right now it is just 32 and so this change makes it 33 bytes adding some wasted padding on RISC-V.

This revision is now accepted and ready to land.Oct 30 2025, 7:46 AM
In D53422#1220314, @jhb wrote:

RISC-V is using a different value for VM_MAX_NAMELEN and should probably be fixed to match arm64/amd64. Right now it is just 32 and so this change makes it 33 bytes adding some wasted padding on RISC-V.

I have a follow-up revision where I move those definitions to a new sys/dev/vmm/vmm_param.h. I'll just combine it with this one.

Consolidate VM_MAX_NAMELEN definitions in this patch too. Add a vmm_param.h
which contains these definitions, so they can be included from machine/vmm_dev.h.

This revision now requires review to proceed.Oct 30 2025, 5:17 PM
This revision is now accepted and ready to land.Nov 3 2025, 7:18 AM
This revision was automatically updated to reflect the committed changes.