From 5d785027da87e40138407d76841f5cdd64914541 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Tue, 22 Jun 2021 12:07:59 +0800 Subject: [PATCH 1/2] vhost_net: validate gso metadata only if socket has vnet header When sock_hlen is zero, there's no need to validate the socket vnet header since it doesn't support that. Signed-off-by: Jason Wang --- drivers/vhost/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index df82b124170e..5034c4949bc4 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -725,7 +725,7 @@ static int vhost_net_build_xdp(struct vhost_net_virtqueue *nvq, hdr = buf; gso = &hdr->gso; - if ((gso->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && + if (nvq->sock_hlen && (gso->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && vhost16_to_cpu(vq, gso->csum_start) + vhost16_to_cpu(vq, gso->csum_offset) + 2 > vhost16_to_cpu(vq, gso->hdr_len)) { -- 2.25.1