lkml.org 
[lkml]   [2021]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: Re: [RFC PATCH 17/17] virtio_ring: Add validation for used length
On Tue, May 25, 2021 at 9:31 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
> 在 2021/5/18 上午7:39, Michael S. Tsirkin 写道:
> > On Mon, May 17, 2021 at 05:08:36PM +0800, Xie Yongji wrote:
> >> This adds validation for used length (might come
> >> from an untrusted device) when it will be used by
> >> virtio device driver.
> >>
> >> Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
> >> ---
> >> drivers/virtio/virtio_ring.c | 22 +++++++++++++++++++---
> >> 1 file changed, 19 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> >> index d999a1d6d271..7d4845d06f21 100644
> >> --- a/drivers/virtio/virtio_ring.c
> >> +++ b/drivers/virtio/virtio_ring.c
> >> @@ -68,11 +68,13 @@
> >> struct vring_desc_state_split {
> >> void *data; /* Data for callback. */
> >> struct vring_desc *indir_desc; /* Indirect descriptor, if any. */
> >> + u32 in_len; /* Total length of writable buffer */
> >> };
> >>
> >> struct vring_desc_state_packed {
> >> void *data; /* Data for callback. */
> >> struct vring_packed_desc *indir_desc; /* Indirect descriptor, if any. */
> >> + u32 in_len; /* Total length of writable buffer */
> >> u16 num; /* Descriptor list length. */
> >> u16 last; /* The last desc state in a list. */
> >> };
> >
> > Hmm for packed it's aligned to 64 bit anyway, so we are not making it
> > any worse. But for split this pushes struct size up by 1/3 increasing
> > cache pressure.
>
>
> We can eliminate this by validating through virtio device driver instead
> of virtio core.
>
> E.g for virtio-net we know the rx buffer size so there's no need to
> store in twice in the core.
>

I see. I have sent the new fix just now.

Thanks,
Yongji

\
 
 \ /
  Last update: 2021-05-25 07:08    [W:0.221 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site