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: <59df9815-577a-4449-b17f-72a6b78d373b@amd.com>
Date: Thu, 1 Aug 2024 12:55:29 +0200
From: Christian König <christian.koenig@....com>
To: Huan Yang <link@...o.com>, Gerd Hoffmann <kraxel@...hat.com>,
 Sumit Semwal <sumit.semwal@...aro.org>, dri-devel@...ts.freedesktop.org,
 linux-media@...r.kernel.org, linaro-mm-sig@...ts.linaro.org,
 linux-kernel@...r.kernel.org
Cc: opensource.kernel@...o.com
Subject: Re: [PATCH 3/5] udmabuf: fix vmap_udmabuf error page set



Am 01.08.24 um 12:45 schrieb Huan Yang:
> Currently vmap_udmabuf set page's array by each folio.
> But, ubuf->folios is only contain's the folio's head page.
>
> That mean we repeatedly mapped the folio head page to the vmalloc area.
>
> This patch fix it, set each folio's page correct, so that pages array
> contains right page, and then map into vmalloc area
>
> Signed-off-by: Huan Yang <link@...o.com>
> ---
>   drivers/dma-buf/udmabuf.c | 17 +++++++++++++----
>   1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
> index a915714c5dce..7ed532342d7f 100644
> --- a/drivers/dma-buf/udmabuf.c
> +++ b/drivers/dma-buf/udmabuf.c
> @@ -77,18 +77,27 @@ static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma)
>   static int vmap_udmabuf(struct dma_buf *buf, struct iosys_map *map)
>   {
>   	struct udmabuf *ubuf = buf->priv;
> -	struct page **pages;
> +	struct page **pages, **tmp;
> +	struct sg_table *sg = ubuf->sg;
> +	struct sg_page_iter piter;
>   	void *vaddr;
> -	pgoff_t pg;
>   
>   	dma_resv_assert_held(buf->resv);
>   
> +	if (!sg) {
> +		sg = get_sg_table(NULL, buf, 0);
> +		if (IS_ERR(sg))
> +			return PTR_ERR(sg);
> +		ubuf->sg = sg;
> +	}
> +
>   	pages = kvmalloc_array(ubuf->pagecount, sizeof(*pages), GFP_KERNEL);
>   	if (!pages)
>   		return -ENOMEM;
> +	tmp = pages;
>   
> -	for (pg = 0; pg < ubuf->pagecount; pg++)
> -		pages[pg] = &ubuf->folios[pg]->page;
> +	for_each_sgtable_page(sg, &piter, 0)
> +		*tmp++ = sg_page_iter_page(&piter);

Again don't abuse the sg table for that!

Regards,
Christian.

>   
>   	vaddr = vm_map_ram(pages, ubuf->pagecount, -1);
>   	kvfree(pages);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ