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] [day] [month] [year] [list]
Date:   Mon, 21 Nov 2016 11:14:40 +0100
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Oleg Drokin <green@...uxhacker.ru>
Cc:     devel@...verdev.osuosl.org,
        Andreas Dilger <andreas.dilger@...el.com>,
        James Simmons <jsimmons@...radead.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Jian Yu <jian.yu@...el.com>,
        Lustre Development List <lustre-devel@...ts.lustre.org>
Subject: Re: [PATCH] staging/lustre: Use proper number of bytes in
 copy_from_user

On Mon, Nov 21, 2016 at 12:46:48AM -0500, Oleg Drokin wrote:
> From: Jian Yu <jian.yu@...el.com>
> 
> This patch removes the usage of MAX_STRING_SIZE from
> copy_from_user() and just copies enough bytes to cover
> count passed in.
> 
> Signed-off-by: Jian Yu <jian.yu@...el.com>
> Reviewed-on: http://review.whamcloud.com/23462
> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8774
> Reviewed-by: John L. Hammond <john.hammond@...el.com>
> Signed-off-by: Oleg Drokin <green@...uxhacker.ru>
> ---
>  drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index 8a2f02f3..db49992 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -400,10 +400,17 @@ int lprocfs_wr_uint(struct file *file, const char __user *buffer,
>  	char dummy[MAX_STRING_SIZE + 1], *end;
>  	unsigned long tmp;
>  
> -	dummy[MAX_STRING_SIZE] = '\0';
> -	if (copy_from_user(dummy, buffer, MAX_STRING_SIZE))
> +	if (count >= sizeof(dummy))
> +		return -EINVAL;
> +
> +	if (count == 0)
> +		return 0;
> +
> +	if (copy_from_user(dummy, buffer, count))
>  		return -EFAULT;
>  
> +	dummy[count] = '\0';
> +

You do know about simple_read_from_buffer(), right?  I suggest using
those simple_* functions where ever you are touching user buffers, like
this code.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ