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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1199326218.16921082.1600051335160.JavaMail.zimbra@redhat.com>
Date:   Sun, 13 Sep 2020 22:42:15 -0400 (EDT)
From:   Jason Wang <jasowang@...hat.com>
To:     Li Wang <li.wang@...driver.com>
Cc:     mst@...hat.com, kvm@...r.kernel.org,
        virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] vhost: reduce stack usage in log_used



----- Original Message -----
> Fix the warning: [-Werror=-Wframe-larger-than=]
> 
> drivers/vhost/vhost.c: In function log_used:
> drivers/vhost/vhost.c:1906:1:
> warning: the frame size of 1040 bytes is larger than 1024 bytes
> 
> Signed-off-by: Li Wang <li.wang@...driver.com>
> ---
>  drivers/vhost/vhost.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index b45519c..41769de 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1884,25 +1884,31 @@ static int log_write_hva(struct vhost_virtqueue *vq,
> u64 hva, u64 len)
>  
>  static int log_used(struct vhost_virtqueue *vq, u64 used_offset, u64 len)
>  {
> -	struct iovec iov[64];
> +	struct iovec *iov;
>  	int i, ret;
>  
>  	if (!vq->iotlb)
>  		return log_write(vq->log_base, vq->log_addr + used_offset, len);
>  
> +	iov = kcalloc(64, sizeof(*iov), GFP_KERNEL);
> +	if (!iov)
> +		return -ENOMEM;

Let's preallocate it in e.g vhost_net_open().

We don't want to fail the log due to -ENOMEM.

Thanks

> +
>  	ret = translate_desc(vq, (uintptr_t)vq->used + used_offset,
>  			     len, iov, 64, VHOST_ACCESS_WO);
>  	if (ret < 0)
> -		return ret;
> +		goto out;
>  
>  	for (i = 0; i < ret; i++) {
>  		ret = log_write_hva(vq,	(uintptr_t)iov[i].iov_base,
>  				    iov[i].iov_len);
>  		if (ret)
> -			return ret;
> +			goto out;
>  	}
>  
> -	return 0;
> +out:
> +	kfree(iov);
> +	return ret;
>  }
>  
>  int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
> --
> 2.7.4
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ