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: <CSMR1BXJMLYU.1YUU6374U6T7H@otso>
Date:   Mon, 15 May 2023 11:37:55 +0200
From:   "Luca Weiss" <luca.weiss@...rphone.com>
To:     "Yang Li" <yang.lee@...ux.alibaba.com>,
        <srinivas.kandagatla@...aro.org>
Cc:     <amahesh@....qualcomm.com>, <arnd@...db.de>,
        <linux-arm-msm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        "Abaci Robot" <abaci@...ux.alibaba.com>
Subject: Re: [PATCH -next] fastrpc: Use memdup_user instead of
 kmalloc/copy_from_user

Hi Yang Li,

On Mon May 15, 2023 at 11:26 AM CEST, Yang Li wrote:
> Use memdup_user rather than duplicating its implementation, which
> makes code simple and easy to understand, and silence the following
> warning:
>
> ./drivers/misc/fastrpc.c:1259:8-15: WARNING opportunity for memdup_user
>
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4949
> Signed-off-by: Yang Li <yang.lee@...ux.alibaba.com>
> ---
>  drivers/misc/fastrpc.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index f60bbf99485c..a897dab13c61 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -1256,16 +1256,9 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
>  		goto err;
>  	}
>  
> -	name = kzalloc(init.namelen, GFP_KERNEL);
> -	if (!name) {
> -		err = -ENOMEM;
> -		goto err;
> -	}
> -
> -	if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.namelen)) {
> -		err = -EFAULT;
> -		goto err_name;
> -	}
> +	name = memdup_user((void __user *)(uintptr_t)init.name, init.namelen);
> +	if (IS_ERR(name))
> +		return PTR_ERR(name);

Don't we still need a "goto err;" here to free args?

Something like this:

  if (IS_ERR(name)) {
      err = PTR_ERR(name);
      goto err;
  }

Regards
Luca


>  
>  	if (!fl->cctx->remote_heap) {
>  		err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ