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]
Message-ID: <CAMuHMdWHTaPkzTdzz-j1rFeT=aAEG+J46fgKiPYrXoAR_DTvtQ@mail.gmail.com>
Date:   Tue, 1 Oct 2019 11:15:16 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Lukasz Majewski <lukma@...x.de>
Cc:     Mark Brown <broonie@...nel.org>,
        Colin Ian King <colin.king@...onical.com>,
        linux-spi <linux-spi@...r.kernel.org>,
        Krzysztof Kozlowski <krzk@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        kbuild test robot <lkp@...el.com>,
        Julia Lawall <julia.lawall@...6.fr>,
        Dan Carpenter <dan.carpenter@...cle.com>
Subject: Re: [PATCH] spi: Avoid calling spi_slave_abort() with kfreed spidev

Hi Lukasz,

On Tue, Oct 1, 2019 at 11:07 AM Lukasz Majewski <lukma@...x.de> wrote:
> Call spi_slave_abort() only when the spidev->spi is !NULL and the
> structure hasn't already been kfreed.
>
> Reported-by: kbuild test robot <lkp@...el.com>
> Reported-by: Julia Lawall <julia.lawall@...6.fr>
> Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
> Signed-off-by: Lukasz Majewski <lukma@...x.de>

Thanks for your patch!

> --- a/drivers/spi/spidev.c
> +++ b/drivers/spi/spidev.c
> @@ -600,15 +600,16 @@ static int spidev_open(struct inode *inode, struct file *filp)
>  static int spidev_release(struct inode *inode, struct file *filp)
>  {
>         struct spidev_data      *spidev;
> +       int dofree;

bool?

>
>         mutex_lock(&device_list_lock);
>         spidev = filp->private_data;
>         filp->private_data = NULL;
> +       dofree = 0;

Why not initialize it at declaration time?

>
>         /* last close? */
>         spidev->users--;
>         if (!spidev->users) {
> -               int             dofree;
>
>                 kfree(spidev->tx_buffer);
>                 spidev->tx_buffer = NULL;
> @@ -628,7 +629,8 @@ static int spidev_release(struct inode *inode, struct file *filp)
>                         kfree(spidev);
>         }
>  #ifdef CONFIG_SPI_SLAVE
> -       spi_slave_abort(spidev->spi);
> +       if (!dofree)
> +               spi_slave_abort(spidev->spi);

Can spidev->spi be NULL, if spidev->users != 0?

>  #endif
>         mutex_unlock(&device_list_lock);

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