Page MenuHomeFreeBSD

bhyve/virtio-scsi: Don't invoke iov_to_buf() in an assert() expression
Needs ReviewPublic

Authored by rosenfeld_grumpf.hope-2000.org on Mar 10 2026, 7:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 12, 7:16 PM
Unknown Object (File)
Sat, Apr 11, 1:09 PM
Unknown Object (File)
Fri, Apr 10, 5:54 AM
Unknown Object (File)
Fri, Apr 10, 4:43 AM
Unknown Object (File)
Thu, Apr 9, 7:12 PM
Unknown Object (File)
Sun, Apr 5, 1:18 PM
Unknown Object (File)
Sun, Mar 29, 11:55 PM
Unknown Object (File)
Sat, Mar 28, 8:00 PM

Details

Reviewers
siva
jhb
markj
emaste
des
Group Reviewers
bhyve
Summary

If anyone would build bhyve with -DNDEBUG, any code in the expression
in assert() won't be executed. Remove the assertion and check the
returned size from iov_to_buf() explicitly, exiting if it is wrong.

Diff Detail

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

Event Timeline

usr.sbin/bhyve/pci_virtio_scsi.c
753
des requested changes to this revision.Mar 11 2026, 12:28 PM
des added a subscriber: des.
des added inline comments.
usr.sbin/bhyve/pci_virtio_scsi.c
751

This still fails to build with gcc.

This revision now requires changes to proceed.Mar 11 2026, 12:28 PM
usr.sbin/bhyve/pci_virtio_scsi.c
751

That's not surprising, given this is a fix for a different issue. Please see https://reviews.freebsd.org/D55800 for the proper fix of the build failure with gcc.

This revision now requires review to proceed.Mar 11 2026, 12:53 PM

Or, something along the lines of:

size_t res __maybe_unused;
res = iov_to_buf(...);
assert (res == VTSCSI_IN_HEADER_LEN(q->vsq_sc);