* [PATCH 1/1] vhost: Added pad cleanup if vnet_hdr is not present.
@ 2024-01-15 19:48 Andrew Melnychenko
2024-01-15 21:44 ` Yuri Benditovich
2024-01-15 22:32 ` Michael S. Tsirkin
0 siblings, 2 replies; 6+ messages in thread
From: Andrew Melnychenko @ 2024-01-15 19:48 UTC (permalink / raw)
To: mst, jasowang, kvm, virtualization, netdev, linux-kernel
Cc: yuri.benditovich, yan
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 <andrew@daynix.com>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] vhost: Added pad cleanup if vnet_hdr is not present.
2024-01-15 19:48 [PATCH 1/1] vhost: Added pad cleanup if vnet_hdr is not present Andrew Melnychenko
@ 2024-01-15 21:44 ` Yuri Benditovich
2024-01-15 22:32 ` Michael S. Tsirkin
1 sibling, 0 replies; 6+ messages in thread
From: Yuri Benditovich @ 2024-01-15 21:44 UTC (permalink / raw)
To: linux-kernel
Cc: mst, jasowang, kvm, virtualization, netdev, yan, Andrew Melnychenko
See also https://issues.redhat.com/browse/RHEL-1303
On Mon, Jan 15, 2024 at 9:48 PM Andrew Melnychenko <andrew@daynix.com> wrote:
>
> 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 <andrew@daynix.com>
> ---
> 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] vhost: Added pad cleanup if vnet_hdr is not present.
2024-01-15 19:48 [PATCH 1/1] vhost: Added pad cleanup if vnet_hdr is not present Andrew Melnychenko
2024-01-15 21:44 ` Yuri Benditovich
@ 2024-01-15 22:32 ` Michael S. Tsirkin
2024-02-08 9:34 ` Yuri Benditovich
2024-02-22 20:02 ` Michael S. Tsirkin
1 sibling, 2 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2024-01-15 22:32 UTC (permalink / raw)
To: Andrew Melnychenko
Cc: jasowang, kvm, virtualization, netdev, linux-kernel,
yuri.benditovich, yan
On Mon, Jan 15, 2024 at 09:48:40PM +0200, Andrew Melnychenko wrote:
> 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 <andrew@daynix.com>
> ---
> 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 >
Hmm need to analyse it to make sure there are no cases where we leak
some data to guest here in case where sock_hlen is set ...
> --
> 2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] vhost: Added pad cleanup if vnet_hdr is not present.
2024-01-15 22:32 ` Michael S. Tsirkin
@ 2024-02-08 9:34 ` Yuri Benditovich
2024-02-22 20:02 ` Michael S. Tsirkin
1 sibling, 0 replies; 6+ messages in thread
From: Yuri Benditovich @ 2024-02-08 9:34 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Andrew Melnychenko, jasowang, kvm, virtualization, netdev,
linux-kernel, yan
Just polite ping
On Tue, Jan 16, 2024 at 12:32 AM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Mon, Jan 15, 2024 at 09:48:40PM +0200, Andrew Melnychenko wrote:
> > 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 <andrew@daynix.com>
> > ---
> > 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 >
>
>
> Hmm need to analyse it to make sure there are no cases where we leak
> some data to guest here in case where sock_hlen is set ...
> > --
> > 2.43.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] vhost: Added pad cleanup if vnet_hdr is not present.
2024-01-15 22:32 ` Michael S. Tsirkin
2024-02-08 9:34 ` Yuri Benditovich
@ 2024-02-22 20:02 ` Michael S. Tsirkin
2024-02-26 10:30 ` Andrew Melnichenko
1 sibling, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2024-02-22 20:02 UTC (permalink / raw)
To: Andrew Melnychenko
Cc: jasowang, kvm, virtualization, netdev, linux-kernel,
yuri.benditovich, yan
On Mon, Jan 15, 2024 at 05:32:25PM -0500, Michael S. Tsirkin wrote:
> On Mon, Jan 15, 2024 at 09:48:40PM +0200, Andrew Melnychenko wrote:
> > 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 <andrew@daynix.com>
> > ---
> > 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 >
>
>
> Hmm need to analyse it to make sure there are no cases where we leak
> some data to guest here in case where sock_hlen is set ...
Could you post this analysis pls?
> > --
> > 2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] vhost: Added pad cleanup if vnet_hdr is not present.
2024-02-22 20:02 ` Michael S. Tsirkin
@ 2024-02-26 10:30 ` Andrew Melnichenko
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Melnichenko @ 2024-02-26 10:30 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: jasowang, kvm, virtualization, netdev, linux-kernel,
yuri.benditovich, yan
Hi all,
Ok, let me prepare a new patch v2, where I'll write a
description/analysis of the issue in the commit message.
On Thu, Feb 22, 2024 at 10:02 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Mon, Jan 15, 2024 at 05:32:25PM -0500, Michael S. Tsirkin wrote:
> > On Mon, Jan 15, 2024 at 09:48:40PM +0200, Andrew Melnychenko wrote:
> > > 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 <andrew@daynix.com>
> > > ---
> > > 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 >
> >
> >
> > Hmm need to analyse it to make sure there are no cases where we leak
> > some data to guest here in case where sock_hlen is set ...
>
>
> Could you post this analysis pls?
>
> > > --
> > > 2.43.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-26 10:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-15 19:48 [PATCH 1/1] vhost: Added pad cleanup if vnet_hdr is not present Andrew Melnychenko
2024-01-15 21:44 ` Yuri Benditovich
2024-01-15 22:32 ` Michael S. Tsirkin
2024-02-08 9:34 ` Yuri Benditovich
2024-02-22 20:02 ` Michael S. Tsirkin
2024-02-26 10:30 ` Andrew Melnichenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).