On Thu, 26 Jun 2025 10:14:45 +0800 Jason Wang wrote:
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -690,13 +690,13 @@ static int vhost_net_build_xdp(struct 
> vhost_net_virtqueue *nvq,
>       if (unlikely(!buf))
>               return -ENOMEM;
>  
> -     copied = copy_from_iter(buf, sock_hlen, from);
> -     if (copied != sock_hlen) {
> +     copied = copy_from_iter(buf + pad - sock_hlen, len, from);
> +     if (copied != len) {
>               ret = -EFAULT;
>               goto err;
>       }
>  
> -     gso = buf;
> +     gso = buf + pad - sock_hlen;
>  
>       if (!sock_hlen)
>               memset(buf, 0, pad);
> @@ -715,12 +715,8 @@ static int vhost_net_build_xdp(struct 
> vhost_net_virtqueue *nvq,
>               }
>       }
>  
> -     len -= sock_hlen;

we used to adjust @len here, now we don't..

> -     copied = copy_from_iter(buf + pad, len, from);
> -     if (copied != len) {
> -             ret = -EFAULT;
> -             goto err;
> -     }
> +     /* pad contains sock_hlen */
> +     memcpy(buf, buf + pad - sock_hlen, sock_hlen);
>  
>       xdp_init_buff(xdp, buflen, NULL);
>       xdp_prepare_buff(xdp, buf, pad, len, true);

.. yet we still use len as the packet size here.
-- 
pw-bot: cr

Reply via email to