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: <20210331102414.GL2065@kadam>
Date:   Wed, 31 Mar 2021 13:24:14 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Yang Yingliang <yangyingliang@...wei.com>
Cc:     linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev,
        johan@...nel.org, elder@...nel.org, gregkh@...uxfoundation.org
Subject: Re: [PATCH -next] staging: greybus: camera: Switch to
 memdup_user_nul()

On Wed, Mar 31, 2021 at 05:52:01PM +0800, Yang Yingliang wrote:
> Use memdup_user_nul() helper instead of open-coding to
> simplify the code.
> 
> Reported-by: Hulk Robot <hulkci@...wei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
> ---
>  drivers/staging/greybus/camera.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c
> index b570e13394ac..0f005facffbc 100644
> --- a/drivers/staging/greybus/camera.c
> +++ b/drivers/staging/greybus/camera.c
> @@ -1120,16 +1120,10 @@ static ssize_t gb_camera_debugfs_write(struct file *file,
>  	if (len > 1024)
>  		return -EINVAL;
>  
> -	kbuf = kmalloc(len + 1, GFP_KERNEL);
> -	if (!kbuf)
> +	kbuf = memdup_user_nul(buf, len);
> +	if (IS_ERR(kbuf))
>  		return -ENOMEM;

return PTR_ERR(kbuf);

>  
> -	if (copy_from_user(kbuf, buf, len)) {
> -		ret = -EFAULT;
> -		goto done;
> -	}
> -
> -	kbuf[len] = '\0';
>  
   ^^^^^^^^
Please delete this blank line so there aren't two blank lines in a row.

>  	ret = op->execute(gcam, kbuf, len);

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ