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] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 8 May 2017 11:28:21 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Geliang Tang <geliangtang@...il.com>
Cc:     Mark Brown <broonie@...nel.org>,
        linux-spi <linux-spi@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] spi: spidev: use memdup_user

On Sat, May 6, 2017 at 5:42 PM, Geliang Tang <geliangtang@...il.com> wrote:
> Use memdup_user() helper instead of open-coding to simplify the code.
>
> Signed-off-by: Geliang Tang <geliangtang@...il.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@...der.be>

> --- a/drivers/spi/spidev.c
> +++ b/drivers/spi/spidev.c
> @@ -325,7 +325,6 @@ static struct spi_ioc_transfer *
>  spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
>                 unsigned *n_ioc)
>  {
> -       struct spi_ioc_transfer *ioc;
>         u32     tmp;
>
>         /* Check type, command number and direction */
> @@ -342,14 +341,7 @@ spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
>                 return NULL;
>
>         /* copy into scratch area */
> -       ioc = kmalloc(tmp, GFP_KERNEL);
> -       if (!ioc)
> -               return ERR_PTR(-ENOMEM);
> -       if (__copy_from_user(ioc, u_ioc, tmp)) {

Note that as memdup_user() calls copy_from_user(), it repeats the access_ok()
check already done by spidev_ioctl().

> -               kfree(ioc);
> -               return ERR_PTR(-EFAULT);
> -       }
> -       return ioc;
> +       return memdup_user(u_ioc, tmp);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ