Skip to content

vsock fails when guest sends large packets to host #535

@r0ci

Description

@r0ci

The vsock implementation fails when guests send large enough packets to the host (> 32KB on x86_64 linux guests).

I think it is caused by this change in the kernel: https://lkml.org/lkml/2025/7/17/487. They're allocating non linear skbs, so packets that are larger than one skb frag are getting split across multiple descriptors. On x86_64 this is 32KB (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER).

The current implementation compares packet length and the descriptor's size, sees it doesn't fit and returns BufDescTooSmall:

// The data buffer should be large enough to fit the size of the data, as described by
// the header descriptor.
if buf_desc.len < pkt.len() {
return Err(VsockError::BufDescTooSmall);
}

Reproducing

# on host
nc -lp 8000

# start container
podman run --runtime=krun --network=pasta:--map-host-loopback=10.10.10.10 --rm -it python:latest
# on container repl
import socket
import time

with socket.create_connection(("10.10.10.10", 8000)) as s:
    sizes = [
        1024 * 32 - 1,
        32 * 1024,
        32 * 1024 + 1,
        64 * 1024,
        96 * 1024,
        96 * 1024 + 1,
    ]

    for size in sizes:
        print(f"Sending {size}")
        d = b"a" * size
        s.sendall(d)
        print("Sent")
        time.sleep(1)

You'll see output like:

sending 32767
sent
sending 32768
sent
sending 32769
[2026-02-07T23:21:56Z ERROR devices::virtio::vsock::device] error reading TX packet: BufDescTooSmall
sent
sending 65536
[2026-02-07T23:21:57Z ERROR devices::virtio::vsock::device] error reading TX packet: BufDescTooSmall
sent
sending 98304
[2026-02-07T23:21:58Z ERROR devices::virtio::vsock::device] error reading TX packet: BufDescTooSmall
sent
sending 98305
<-- hangs here until I interrupt

host kernel: 6.18.9-2
guest kernel: 6.12.68
libkrun 1.17.1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions