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]
Message-ID: <20211210100450.GN1956@kadam>
Date:   Fri, 10 Dec 2021 13:04:50 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Cc:     Larry.Finger@...inger.net, phil@...lpotter.co.uk,
        gregkh@...uxfoundation.org, linux-staging@...ts.linux.dev,
        linux-kernel@...r.kernel.org, Abaci Robot <abaci@...ux.alibaba.com>
Subject: Re: [PATCH v2] staging: r8188eu: Use strndup_user instead of
 kmalloc/copy_from_user

On Fri, Dec 10, 2021 at 05:37:01PM +0800, Jiapeng Chong wrote:
> This code assumes that the user is going to give us a NULL terminated

I wouldn't comment on this except that the Fixes tag is wrong so it
needs to be resent anyway.  NULL is a pointer.  When it's a character
'\0'; then it's just one L "NUL terminated".

> string which is not necessarily true.  The original code was buggy too.
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Leave this out.

> 
> Fix following coccicheck warning:
> 
> ./drivers/staging/r8188eu/os_dep/ioctl_linux.c:4253:8-15: WARNING
> opportunity for memdup_user.
> 
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Fixes: 7bdedfef085b ("staging: r8188eu: Remove mp, a.k.a. manufacturing process, code")

The fixes tag should be:

Fixes: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for RTL8188eu driver")


> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> ---
> Changes in v2:
>   -For the follow advice:https://lore.kernel.org/lkml/20211210083010.GM1956@kadam/

Don't put a link in the email.  Just say what the difference is.  No
one wants to have to click on a link.

> 
>  drivers/staging/r8188eu/os_dep/ioctl_linux.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> index 56adfe4087a8..5d26dffe5c0d 100644
> --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> @@ -4250,17 +4250,12 @@ static int rtw_test(
>  	DBG_88E("+%s\n", __func__);
>  	len = wrqu->data.length;
>  
> -	pbuf = kzalloc(len, GFP_KERNEL);
> -	if (!pbuf) {
> -		DBG_88E("%s: no memory!\n", __func__);
> -		return -ENOMEM;
> -	}
> -
> -	if (copy_from_user(pbuf, wrqu->data.pointer, len)) {
> -		kfree(pbuf);
> +	pbuf = strndup_user(wrqu->data.pointer, len);
> +	if (IS_ERR(pbuf)) {
>  		DBG_88E("%s: copy from user fail!\n", __func__);

This printk is out of date now that we're not using the copy_from_user()
function.  It doesn't add useful information.  Just delete it.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ