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: <CAPDyKFp4tt4xA-Fo_E7yWV2Mi4ES5ko=g1XgfaJwxhkSiaCEMg@mail.gmail.com>
Date:   Tue, 19 Oct 2021 13:36:59 +0200
From:   Ulf Hansson <ulf.hansson@...aro.org>
To:     Zheyu Ma <zheyuma97@...il.com>
Cc:     Maxim Levitsky <maximlevitsky@...il.com>,
        Alex Dubov <oakad@...oo.com>,
        linux-mmc <linux-mmc@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] memstick: r592: Fix a UAF bug when removing the driver

On Sat, 16 Oct 2021 at 13:26, Zheyu Ma <zheyuma97@...il.com> wrote:
>
> In r592_remove(), the driver will free dma after freeing the host, which
> may cause a UAF bug.
>
> The following log reveals it:
>
> [   45.361796 ] BUG: KASAN: use-after-free in r592_remove+0x269/0x350 [r592]
> [   45.364286 ] Call Trace:
> [   45.364472 ]  dump_stack_lvl+0xa8/0xd1
> [   45.364751 ]  print_address_description+0x87/0x3b0
> [   45.365137 ]  kasan_report+0x172/0x1c0
> [   45.365415 ]  ? r592_remove+0x269/0x350 [r592]
> [   45.365834 ]  ? r592_remove+0x269/0x350 [r592]
> [   45.366168 ]  __asan_report_load8_noabort+0x14/0x20
> [   45.366531 ]  r592_remove+0x269/0x350 [r592]
> [   45.378785 ]
> [   45.378903 ] Allocated by task 4674:
> [   45.379162 ]  ____kasan_kmalloc+0xb5/0xe0
> [   45.379455 ]  __kasan_kmalloc+0x9/0x10
> [   45.379730 ]  __kmalloc+0x150/0x280
> [   45.379984 ]  memstick_alloc_host+0x2a/0x190
> [   45.380664 ]
> [   45.380781 ] Freed by task 5509:
> [   45.381014 ]  kasan_set_track+0x3d/0x70
> [   45.381293 ]  kasan_set_free_info+0x23/0x40
> [   45.381635 ]  ____kasan_slab_free+0x10b/0x140
> [   45.381950 ]  __kasan_slab_free+0x11/0x20
> [   45.382241 ]  slab_free_freelist_hook+0x81/0x150
> [   45.382575 ]  kfree+0x13e/0x290
> [   45.382805 ]  memstick_free+0x1c/0x20
> [   45.383070 ]  device_release+0x9c/0x1d0
> [   45.383349 ]  kobject_put+0x2ef/0x4c0
> [   45.383616 ]  put_device+0x1f/0x30
> [   45.383865 ]  memstick_free_host+0x24/0x30
> [   45.384162 ]  r592_remove+0x242/0x350 [r592]
> [   45.384473 ]  pci_device_remove+0xa9/0x250
>
> Signed-off-by: Zheyu Ma <zheyuma97@...il.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/memstick/host/r592.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
> index e79a0218c492..1d35d147552d 100644
> --- a/drivers/memstick/host/r592.c
> +++ b/drivers/memstick/host/r592.c
> @@ -838,15 +838,15 @@ static void r592_remove(struct pci_dev *pdev)
>         }
>         memstick_remove_host(dev->host);
>
> +       if (dev->dummy_dma_page)
> +               dma_free_coherent(&pdev->dev, PAGE_SIZE, dev->dummy_dma_page,
> +                       dev->dummy_dma_page_physical_address);
> +
>         free_irq(dev->irq, dev);
>         iounmap(dev->mmio);
>         pci_release_regions(pdev);
>         pci_disable_device(pdev);
>         memstick_free_host(dev->host);
> -
> -       if (dev->dummy_dma_page)
> -               dma_free_coherent(&pdev->dev, PAGE_SIZE, dev->dummy_dma_page,
> -                       dev->dummy_dma_page_physical_address);
>  }
>
>  #ifdef CONFIG_PM_SLEEP
> --
> 2.17.6
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ