Thread (6 messages) 6 messages, 3 authors, 2024-02-26

Re: [PATCH 1/1] vhost: Added pad cleanup if vnet_hdr is not present.

From: Yuri Benditovich <hidden>
Date: 2024-01-15 21:44:47
Also in: kvm, lkml, virtualization

See also https://issues.redhat.com/browse/RHEL-1303


On Mon, Jan 15, 2024 at 9:48 PM Andrew Melnychenko [off-list ref] wrote:
quoted hunk ↗ jump to hunk
When the Qemu launched with vhost but without tap vnet_hdr,
vhost tries to copy vnet_hdr from socket iter with size 0
to the page that may contain some trash.
That trash can be interpreted as unpredictable values for
vnet_hdr.
That leads to dropping some packets and in some cases to
stalling vhost routine when the vhost_net tries to process
packets and fails in a loop.

Qemu options:
  -netdev tap,vhost=on,vnet_hdr=off,...

Signed-off-by: Andrew Melnychenko <redacted>
---
 drivers/vhost/net.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index f2ed7167c848..57411ac2d08b 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -735,6 +735,9 @@ static int vhost_net_build_xdp(struct vhost_net_virtqueue *nvq,
        hdr = buf;
        gso = &hdr->gso;

+       if (!sock_hlen)
+               memset(buf, 0, pad);
+
        if ((gso->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
            vhost16_to_cpu(vq, gso->csum_start) +
            vhost16_to_cpu(vq, gso->csum_offset) + 2 >
--
2.43.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help