[Bug 300846] bhyve: virtio-net RX uses a NULL iov for an unmapped descriptor

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 17 Nov 2026 16:08:54 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300846

            Bug ID: 300846
           Summary: bhyve: virtio-net RX uses a NULL iov for an unmapped
                    descriptor
           Product: Base System
           Version: 15.1-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bhyve
          Assignee: virtualization@FreeBSD.org
          Reporter: 1350430676@qq.com

Created attachment 277399
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277399&action=edit
Reproduction bundle: PoC source, test script, runtime logs, crash output, and
SHA-256 manifest.

Environment:
- FreeBSD 15.1-RELEASE-p3 with snapshot-enabled bhyve/bhyvectl.
- Source releng/15.1 commit 88e7371d9.
- Device: virtio-net at 0:2:0.

_vq_record() stores the result of paddr_guest2host(). If the descriptor GPA is
unmapped, the iov base is NULL while the iov length remains non-zero.
pci_vtnet_rx() later writes the virtio header through that base with memset().

Steps to reproduce:
1. Publish a writable RX descriptor with addr=0x80000000 and len=2048.
2. Do not notify the RX queue.
3. Save normally and restore the unmodified snapshot.
4. Send one frame to the tap interface.

Expected: mapping failure rejects the descriptor chain.
Actual on p3: mevent thread SIGSEGV at address 0, bhyve exit 139.

Current main c8e73127e now warns on a failed mapping, but returns from
_vq_record() after storing iov_len and does not make vq_getchain() fail. The
NULL entry can still reach the memset at pci_virtio_net.c:345. The stable p6
source lacks even that warning.

Impact: denial of service and loss of the VM. The same descriptor can also be
consumed without save/restore.

Suggested fix:
- Propagate mapping failure from _vq_record() and reject the full chain.
- Clear the iov entry on failure.
- Check iov_base before writing the virtio header.
- Audit all consumers of vq_getchain().

-- 
You are receiving this mail because:
You are the assignee for the bug.