lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a5cfe66f-5ae2-1a73-6010-74123721135b@redhat.com>
Date:   Mon, 16 Nov 2020 12:32:02 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Stefano Garzarella <sgarzare@...hat.com>,
        virtualization@...ts.linux-foundation.org
Cc:     Stefan Hajnoczi <stefanha@...hat.com>,
        Laurent Vivier <lvivier@...hat.com>,
        linux-kernel@...r.kernel.org, Eli Cohen <elic@...dia.com>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Max Gurtovoy <mgurtovoy@...dia.com>
Subject: Re: [PATCH RFC 11/12] vringh: allow vringh_iov_xfer() to skip bytes
 when ptr is NULL


On 2020/11/13 下午9:47, Stefano Garzarella wrote:
> In some cases, it may be useful to provide a way to skip a number
> of bytes in a vringh_iov.
>
> In order to keep vringh_iov consistent, let's reuse vringh_iov_xfer()
> logic and skip bytes when the ptr is NULL.
>
> Signed-off-by: Stefano Garzarella <sgarzare@...hat.com>
> ---
>
> I'm not sure if this is the best option, maybe we can add a new
> function vringh_iov_skip().
>
> Suggestions?


I might be worth to check whether we can convert vringh_iov to use iov 
iterator then we can use iov_iterator_advance() here.

Thanks


> ---
>   drivers/vhost/vringh.c | 16 +++++++++++-----
>   1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
> index 8bd8b403f087..ed3290946ad7 100644
> --- a/drivers/vhost/vringh.c
> +++ b/drivers/vhost/vringh.c
> @@ -75,7 +75,9 @@ static inline int __vringh_get_head(const struct vringh *vrh,
>   	return head;
>   }
>   
> -/* Copy some bytes to/from the iovec.  Returns num copied. */
> +/* Copy some bytes to/from the iovec.  Returns num copied.
> + * If ptr is NULL, skips at most len bytes.
> + */
>   static inline ssize_t vringh_iov_xfer(struct vringh *vrh,
>   				      struct vringh_kiov *iov,
>   				      void *ptr, size_t len,
> @@ -89,12 +91,16 @@ static inline ssize_t vringh_iov_xfer(struct vringh *vrh,
>   		size_t partlen;
>   
>   		partlen = min(iov->iov[iov->i].iov_len, len);
> -		err = xfer(vrh, iov->iov[iov->i].iov_base, ptr, partlen);
> -		if (err)
> -			return err;
> +
> +		if (ptr) {
> +			err = xfer(vrh, iov->iov[iov->i].iov_base, ptr, partlen);
> +			if (err)
> +				return err;
> +			ptr += partlen;
> +		}
> +
>   		done += partlen;
>   		len -= partlen;
> -		ptr += partlen;
>   		iov->consumed += partlen;
>   		iov->iov[iov->i].iov_len -= partlen;
>   		iov->iov[iov->i].iov_base += partlen;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ