The NetWorker thread in the host can panic if a guest sends a virtio-net packet with a total descriptor length less than the virtio-net header size (VNET_HDR_LEN, which is 12 bytes). This happens because the write_frame method (e.g., in the Unixgram backend) attempts to slice the buffer using VNET_HDR_LEN as the start index (&buf[hdr_len..]). If the buffer's length (derived from the guest's descriptor chain) is smaller than hdr_len, Rust will panic. A malicious guest can exploit this to crash the networking worker thread of the host, leading to a Denial of Service.
self.tx_frame_len = read_count;
if read_count < VNET_HDR_LEN {
tx_queue
.add_used(&self.mem, head_index, 0)
.map_err(TxError::QueueError)?;
raise_irq = true;
continue;
}
match self
.backend
.write_frame(VNET_HDR_LEN, &mut self.tx_frame_buf[..read_count])
Originally posted by @gemini-code-assist[bot] in #574 (comment)