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: <CAHUa44E8CoELCPr6EXRf+CgcfK7Jj6sJA061QGQgkGMiOL7A1A@mail.gmail.com>
Date:   Mon, 12 Jun 2023 14:37:36 +0200
From:   Jens Wiklander <jens.wiklander@...aro.org>
To:     Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Cc:     sumit.garg@...aro.org, op-tee@...ts.trustedfirmware.org,
        linux-kernel@...r.kernel.org, Abaci Robot <abaci@...ux.alibaba.com>
Subject: Re: [PATCH] tee: optee: Use kmemdup() to replace kmalloc + memcpy

On Fri, Jun 9, 2023 at 9:15 AM Jiapeng Chong
<jiapeng.chong@...ux.alibaba.com> wrote:
>
> ./drivers/tee/optee/smc_abi.c:1542:12-19: WARNING opportunity for kmemdup.
>
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5480
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> ---
>  drivers/tee/optee/smc_abi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Looks good, but would you mind elaborating a little in the commit
message? A sentence explaining what's going on should be enough.

Thanks,
Jens

>
> diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
> index 3861ae06d902..d5b28fd35d66 100644
> --- a/drivers/tee/optee/smc_abi.c
> +++ b/drivers/tee/optee/smc_abi.c
> @@ -1541,12 +1541,11 @@ static int optee_load_fw(struct platform_device *pdev,
>          * This uses the GFP_DMA flag to ensure we are allocated memory in the
>          * 32-bit space since TF-A cannot map memory beyond the 32-bit boundary.
>          */
> -       data_buf = kmalloc(fw->size, GFP_KERNEL | GFP_DMA);
> +       data_buf = kmemdup(fw->data, fw->size, GFP_KERNEL | GFP_DMA);
>         if (!data_buf) {
>                 rc = -ENOMEM;
>                 goto fw_err;
>         }
> -       memcpy(data_buf, fw->data, fw->size);
>         data_pa = virt_to_phys(data_buf);
>         reg_pair_from_64(&data_pa_high, &data_pa_low, data_pa);
>         reg_pair_from_64(&data_size_high, &data_size_low, data_size);
> --
> 2.20.1.7.g153144c
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ