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:   Sat, 14 May 2022 14:50:11 +0200
From:   Bartosz Golaszewski <brgl@...ev.pl>
To:     Zheyu Ma <zheyuma97@...il.com>
Cc:     Andy Shevchenko <andy@...nel.org>,
        Linus Walleij <linus.walleij@...aro.org>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] gpio: ml-ioh: Add devm_free_irq() call to remove flow

On Thu, May 12, 2022 at 2:48 PM Zheyu Ma <zheyuma97@...il.com> wrote:
>
> When removing the module, we will get the following flaw:
>
> [   14.204955] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'gpio_ml_ioh'
> [   14.205827] WARNING: CPU: 0 PID: 305 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
> [   14.209994] RIP: 0010:remove_proc_entry+0x389/0x3f0
> [   14.217820] Call Trace:
> [   14.218264]  unregister_irq_proc+0x14c/0x170
> [   14.220206]  pci_disable_device+0x1ad/0x380
> [   14.220613]  ioh_gpio_remove+0xc5/0xe0 [gpio_ml_ioh]
>
> Fix this bug by adding devm_free_irq() call to remove flow.
>
> Fixes: e971ac9a564a ("gpio: ml-ioh: use resource management for irqs")
> Signed-off-by: Zheyu Ma <zheyuma97@...il.com>
> ---
> Changes in v2:
>     - Remove unimportant lines from the call trace.
>     - Add the fixes tag.
> ---
>  drivers/gpio/gpio-ml-ioh.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
> index b060c4773698..09bf317876b0 100644
> --- a/drivers/gpio/gpio-ml-ioh.c
> +++ b/drivers/gpio/gpio-ml-ioh.c
> @@ -508,6 +508,8 @@ static void ioh_gpio_remove(struct pci_dev *pdev)
>         struct ioh_gpio *chip = pci_get_drvdata(pdev);
>         void *chip_save;
>
> +       devm_free_irq(&pdev->dev, pdev->irq, chip);
> +

If you need to use devm_free_anything() in the remove callback then
something is simply wrong in the resource handling. Can you instead
use devm_gpiochip_add_data() in probe? This most likely would fix this
problem because it would correctly order the freeing of resources.

Bart

>         chip_save = chip;
>
>         for (i = 0; i < 8; i++, chip++)
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ