summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd
AgeCommit message (Collapse)Author
2022-03-07Resolve clang unused-but-set warnings in vmd's vioscsi.c.Dave Voutila
A few of the vioscsi functions have debug logging in DPRINTF's and are the only use of some declared variables. This tucks any debug-only variables into the DPRINTF or behind an #if DEBUG. ok from deraadt@ caveated I don't add code before any declarations.
2022-03-01vmd(8): gracefully handle hitting data limits when starting a vmDave Voutila
With recent changes to login.conf(5) to restrict daemon datasize to a finite value, users can now hit resource limits when attempting to start a vm. This change fixes the error path when hitting the limit. vmd(8) will no longer abort and memory error messages are relayed to the user. While here, address potential under-reads/writes using atomicio when relaying data between the child vm process and vmd's vmm process. Original diff from tedu@. OK mlarkin@.
2022-01-28When it's the possessive of 'it', it's spelled "its", without thePhilip Guenther
apostrophe.
2022-01-15vmd: Remove a warning about non-32KHz timebasesMike Larkin
Remove a warning that has outlived its usefulness. From Brian Conway, thanks.
2022-01-05adjust Xr for fw_update to section 8;Jason McIntyre
ok afresh sthen deraadt
2022-01-04Try to handle possible vm_register() failures and return an error backClaudio Jeker
to the caller instead of most probably crashing because of a NULL pointer access. This fixes also another -Wunused-but-set-variable warning. OK benno@ dv@
2022-01-04Remove unused imsg type IMSG_VMDOP_RECEIVE_VM_RESPONSE.Claudio Jeker
OK benno@ dv@
2022-01-04Another -Wunused-but-set-variable fix.Claudio Jeker
Based on input from dv@
2022-01-04Fix some simple -Wunused-but-set-variable warnings.Claudio Jeker
OK benno@ dv@
2021-12-30Add back support for -B net -b bsd.rd which emulates a PXE install andClaudio Jeker
results in an autoinstall. This can be used to quickly create new OpenBSD installs. OK dv@
2021-12-13including sys/cdefs.h manually started as a result of netbsd trying toTheo de Raadt
macro-build a replacement for sccsid, and was done without any concern for namespace damage. Unfortunately this practice started infecting other code as others were unaware they didn't need the file. ok millert guenther
2021-11-29mostly avoid sys/param.h with a local nitems()Theo de Raadt
ok mlarkin
2021-11-11switch(4) is being retired, sthen@ already removed the bits in the codeClaudio Jeker
adjust the man page as well. OK sthen@ kn@ patrick@
2021-11-10Remove switch(4) pieces, feedback/missing piece millert@ ok claudio@ mlarkin@Stuart Henderson
2021-11-05Fix bootorder string for diskJan Klemkow
ok mlarkin@
2021-11-04Fix broken "boot device cdrom" feature after a fix in seabios.Jan Klemkow
seabios fixes wrong LUN handling upstream. Thus, we have to adapt the LUN of our cdrom bootorder string, too. ok brynet@, dv@
2021-10-15Don't declare variables as "unsigned char *" that are passed toChristian Weisgerber
functions that take "char *" arguments. Where such chars are assigned to int or passed to ctype functions, explicitly cast them to unsigned char. For OpenBSD's clang, -Wpointer-sign has been disabled by default, but when the parse.y code was built elsewhere, the compiler would complain. With help from millert@ ok benno@ deraadt@
2021-09-01remove unused functions and cleanup vmd.hDave Voutila
Discussed with mlarkin@. These functions were implemented but never used. While in vmd.h, fix the order to match current vmd(8) reality.
2021-08-29Mask viornd descriptor value to prevent out of bound reads.Dave Voutila
viornd did not mask the descriptor value in the avialable ring allowing guest values to read past the end of the descriptor table. While here, change fatal to fatalx because errno is not set. Reported by Ilja van Sprundel ok mlarkin@
2021-08-29mask next descriptor value and fix chunk_size calculationDave Voutila
Guest can cause out of bounds read with a malformed descriptor. In same loop, also fix a chunk size calculation. Reported by Ilja van Sprundel. ok mlarkin@
2021-08-29check for null vioblk infoDave Voutila
If {c,m}alloc fail, info could be NULL and result in NULL deref. Reported by Ilja van Sprundel. ok mlarkin@
2021-08-29correct device status write sizeDave Voutila
Reported by Ilja van Sprundel. ok mlarkin@
2021-08-29remove old descriptor dump functionDave Voutila
Used originally to aid dev. Unneeded. ok mlarkin@
2021-07-18vmd(8): remove invalid errno values from config_setvmdv
Refactor config_setvm to directly return error code on failure instead of returning -1 and setting errno. It was setting unsupported values not defined in <errno.h>. OK mlarkin@
2021-07-16vmd(8): simplify vcpu logic, removing uart & vionet readsdv
Remove legacy state handling on the ns8250 and virtio network devices originally put in place before using libevent for async device events. The vcpu thread doesn't need to process device data as it is handled by the libevent thread. This has the benefit of simplifying some of the message passing between threads introduced to the ns8250 uart since both the vcpu and libevent threads were processing read events. No functional change intended. Tested by many, including abieber@, weerd@, Mischa Peters, and Matthias Schmidt. (Thanks.) OK mlarkin@
2021-06-21vmd(8): support variable length vionet rx descriptor chainsdv
The original implementation of the virtio network device assumed a driver would only provide a 2-descriptor chain for receiving packets. The virtio spec allows for variable length chains and drivers, in practice, construct them when they use a sufficiently large MTU. This change lets the device use variable length chains provided by the driver, thus allowing for drivers to set an MTU up to the underlying host-side tap(4)'s limit of TUNMRU (16384). Size limitations are now enforced on both tx and rx-side dropping anything violating the underlying tap(4) min and max limits. More work is needed to increase the read(2) buffer in use by vmd to prevent packet truncation. OK mlarkin@
2021-06-17vmd(8): handle VIRTIO_BLK_T_GET_ID, check descriptor r/w flagsdv
Linux guests like to issue VIRTIO_BLK_T_GET_ID commands in attempts to read the device serial number. It's not part of the virtio spec, but has been part of QEMU and Bhyve for multiple years. It will be landing in the next version of virtio (1.2), so this stubs out handling for the request type. The added benefit is it helps squelch log noise from Linux guests. For now, no serial number is set and the request status is set to VIRTIO_BLK_S_UNSUPP to tell the driver we don't support it. While here, swap the response to VIRTIO_BLK_T_FLUSH{,_OUT} to be also returning VIRTIO_BLK_S_UNSUPP. It's not negotiated nor implemented. Lastly, add checks for validating the vioblk device is only reading/writing descriptors with approrpriate read/write-only flags per the virtio spec. With input from claudio@, OK mlarkin@
2021-06-16cleanup vmd(8) includes and header filesdv
Lots of organic growth other the years lead to unnecessary includes (proc.h everywhere) and odd dependencies between header files. This cleans things up a bit to help with upcoming cleanup around dhcp code. No functional change. "go for it" mlarkin@
2021-06-15Filter out packets that are not IPv4. This code came from dhcp programsClaudio Jeker
where this filtering was done in bpf but here vmd needs to make sure to not look at non IPv4 packets. OK florian@ and dv@
2021-06-11vmd(8): deduplicate vioblk command logicdv
No need for each case in the switch block to have the same logic for updating the used ring and writing the state back to the guest. Move it outside the switch. No functional change. ok mlarkin@
2021-06-10vmctl(8)/vmd(8): communicate TERMINATE_VM_EVENT imsgs on vm stop.dv
Instead of translating imsg types, update vmclt(8) to handle receiving IMSG_VMDOP_TERMINATE_VM_EVENT messages on vm termination. This finishes the work previously committed for supporting multiple waiters or the cancellation of a client waiting on a vm shutdown. vmd no longer needs to translate an IMSG_VMDOP_TERMINATE_VM_RESPONSE into an *_EVENT. ok mlarkin@
2021-06-08vmd(8): malicious dhcp packets on local ifs can cause stack overflowsdv
A sufficiently large dhcp packet can cause a stack overflow in vmd's internal dhcp server used for providing ip addresses to local guest interfaces. (This does not affect non-local interfaces.) The primary changes drop larger packets and change the memory copying logic to use a compile-time constant. The dhcp option processing also additional prevention for out of bound reads. While here, improve construction of the dhcp response's hostname handling to guard against overflowing the response dhcp options. Vulnerability reported by Maxime Villard. ok claudio@
2021-06-02vmd(8): allow locking a randomly assigned lladdrdv
Provide a default value of a zero'd mac address so a user can still specify the interface should be "locked" (only transmitting ethernet packets with a matching source address). vmd will assign a random address at vm launch. As an example, this is now valid: vm "name" { interface { locked lladdr } ... } From Martin Vahlensieck ok claudio@
2021-05-23vmd(8): skip inspecting non-udp packets on local interfacesdv
reyk@ imported packet.c from (I think) dhclient(8). In dhclient, the packets are already filtered down to just udp. This change has vmd skip a non-udp ip packet sooner when it's trying to determine if it is a dhcp/bootp packet that needs processing. The counters (seen, bad checksums, etc) for ip and udp packets are also removed as they aren't used by vmd. This only affects "local" network interfaces for vmd. OK mlarkin@
2021-05-18vmd(8): guest virtio drivers can cause stack & buffer overflowsdv
A vmd guest can craft invalid virtio descriptor lengths resulting in reading and writing beyond stack-allocated buffer lengths providing an escape vector to the host. Instead of allowing the guest to dictate read/write lengths, this commit has vmd just use compile-time lengths based on the source or destination object sizes. For instances where vmd's virtio implementation can't use this method, such as reading packets from the vionet device, cap each read with a pre-computed max chunk size. Reported by Maxime Villard. Tested with help from Mischa Peters, OK mlarkin@
2021-05-12vmd(8): omit a possibly uninitialized var in a log_warnxMike Larkin
Don't print 'base' since it might not be initialized in all code paths. From James Cook
2021-05-05Refactor vm_instance to return error value directly.dv
vmd(8)'s vm_instance function set unsupported errno values. Change the api to directly return an error (either errno or custom vmd error). "go for it" -mlarkin@
2021-05-04gzread(3) doesn't always set errno, so use gzerror(3)dv
Compression errors from libz don't set errno. OK mlarkin@
2021-05-04Move unused task queue stuff to the attic.dv
Was added about 4 years ago, but hasn't been used and linked into the build. Discussed with dlg@ and mlarkin@. mlarkin@: "Let's remove for now..."
2021-05-04Init debug logging state before attempting to log.dv
Error messages related to bad configuration were not flushing to stderr. OK mlarkin@
2021-04-29Linting: remove duplicate struct definition (plus whitespace)dv
"sure" mlarkin@
2021-04-26vmd(8): fix vmctl client "wait" state corruptiondv
Adds queue-based tracking of waiting client state to fix the cause of state corruption when a vmctl(8) user cancels a wait and restarts it. The socket fd value for the control process client was being used to track the waiting party, but this also prevented multiple waiting clients. This moves all the state tracking of who to notify of a vm's stopping to the control process and no longer requires the parent process to track it in the global environment state. Future work will be needed to smooth out the difference between the IMSG_VMDOP_TERMINATE_VM_{EVENT,RESPONSE} events instead of needing to translate before relaying to the vmctl(8) client. Tested by Mischa Peters (thanks!) ok mlarkin@
2021-04-22vmd(8): guard against bad virtio driversdv
Add protections against guests with bad virtio-{blk,net,scsi} drivers, specifically avoiding invalid descriptor chains and invalid vionet packet sizes. This helps prevent possible lockup of the host vm process due to a spinning device event loop thread. Also fix an unneeded cast in the vioblk handling in case of invalid buffer lengths. OK mlarkin@
2021-04-22Remove trailing whitespace in comment blocks.dv
2021-04-21Fix packet size checks and remove bad casts.dv
Because dhcpsz was an uninitialized ssize_t, it was possible that a garbage "packet" would be queued on the receiving end of the virtio network device. Change the type to size_t and add proper checks based on it being greater than zero. Remove the cast of ssize_t to uint64_t that also caused garbage sizes when dhcpsz was unintialized and set at runtime to something < 0.
2021-04-20Move TAILQ initialization to files where they are used.dv
These priv-sep daemons all follow a similar design and use TAILQs for tracking control process connections. In most cases, the TAILQs are initialized separate from where they are used. Since the scope of use is generally confined to a specific control process file, this commit also removes any extern definitions and exposing the TAILQ structures to other compilation units. ok bluhm@, tb@
2021-04-11KNF, capitalization, whitespacedv
2021-04-11Remove dead code for unused IMSG_CTL_NOTIFY messages.dv
Some vestigial code left over from when priv-sep was implemented. ok mlarkin@
2021-04-11Correct a comment: reference the correct filedv
2021-04-05Support booting from compressed kernel images.dv
The bsd.rd ramdisk now ships gzip'd on amd64. Use libz in base to transparently handle decompression of any compressed kernel images. Patch from Josh Rickmar. ok kn@