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: <CALiNf2_Ubi9cynH1Rjy-o87V3MyvdTazv5rO=sggNai0WJZ81g@mail.gmail.com>
Date:   Tue, 20 Jul 2021 11:36:19 +0800
From:   Claire Chang <tientzu@...omium.org>
To:     Will Deacon <will@...nel.org>
Cc:     "list@....net:IOMMU DRIVERS <iommu@...ts.linux-foundation.org>, Joerg
        Roedel <joro@...tes.org>," <iommu@...ts.linux-foundation.org>,
        lkml <linux-kernel@...r.kernel.org>,
        Guenter Roeck <linux@...ck-us.net>,
        Christoph Hellwig <hch@....de>,
        Robin Murphy <robin.murphy@....com>,
        Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
        Nathan Chancellor <nathan@...nel.org>
Subject: Re: [PATCH 5/5] swiotlb: Free tbl memory in swiotlb_exit()

On Mon, Jul 19, 2021 at 8:31 PM Will Deacon <will@...nel.org> wrote:
>
> Although swiotlb_exit() frees the 'slots' metadata array referenced by
> 'io_tlb_default_mem', it leaves the underlying buffer pages allocated
> despite no longer being usable.
>
> Extend swiotlb_exit() to free the buffer pages as well as the slots
> array.
>
> Cc: Claire Chang <tientzu@...omium.org>
> Cc: Christoph Hellwig <hch@....de>
> Cc: Robin Murphy <robin.murphy@....com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
> Tested-by: Nathan Chancellor <nathan@...nel.org>

Tested-by: Claire Chang <tientzu@...omium.org>

> Signed-off-by: Will Deacon <will@...nel.org>
> ---
>  kernel/dma/swiotlb.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index b3c793ed9e64..87c40517e822 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
> @@ -328,18 +328,27 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
>
>  void __init swiotlb_exit(void)
>  {
> -       size_t size;
>         struct io_tlb_mem *mem = &io_tlb_default_mem;
> +       unsigned long tbl_vaddr;
> +       size_t tbl_size, slots_size;
>
>         if (!mem->nslabs)
>                 return;
>
>         pr_info("tearing down default memory pool\n");
> -       size = array_size(sizeof(*mem->slots), mem->nslabs);
> -       if (mem->late_alloc)
> -               free_pages((unsigned long)mem->slots, get_order(size));
> -       else
> -               memblock_free_late(__pa(mem->slots), PAGE_ALIGN(size));
> +       tbl_vaddr = (unsigned long)phys_to_virt(mem->start);
> +       tbl_size = PAGE_ALIGN(mem->end - mem->start);
> +       slots_size = PAGE_ALIGN(array_size(sizeof(*mem->slots), mem->nslabs));
> +
> +       set_memory_encrypted(tbl_vaddr, tbl_size >> PAGE_SHIFT);
> +       if (mem->late_alloc) {
> +               free_pages(tbl_vaddr, get_order(tbl_size));
> +               free_pages((unsigned long)mem->slots, get_order(slots_size));
> +       } else {
> +               memblock_free_late(mem->start, tbl_size);
> +               memblock_free_late(__pa(mem->slots), slots_size);
> +       }
> +
>         memset(mem, 0, sizeof(*mem));
>  }
>
> --
> 2.32.0.402.g57bb445576-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ