virtio-devices: vsock: Add bounds check on inline TX path

The TX path's inline-data branch didn't check the inline buffer length
against the guest-supplied pkt.len() field. The worker will later panic
when it tries to index the packet.

Add the missing check, mirroring the other TX branches.

Signed-off-by: Dylan Reid <dgreid@fb.com>
This commit is contained in:
Dylan Reid
2026-04-24 16:58:07 -07:00
committed by Rob Bradford
parent 02b503ee16
commit 9f405a21ac

View File

@@ -175,6 +175,9 @@ impl VsockPacket {
// For small packets, the data may be stored in the same descriptor as the header.
if !head.has_next() {
let buf_size: usize = head.len() as usize - VSOCK_PKT_HDR_SIZE;
if buf_size < pkt.len() as usize {
return Err(VsockError::BufDescTooSmall);
}
let buf_ptr = get_host_address_range(
desc_chain.memory(),
head.addr()