xen/gntdev: Fix the abuse of underlying struct page in DMA-buf import
authorOleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Sun, 7 Jan 2024 10:34:26 +0000 (12:34 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Feb 2024 20:14:31 +0000 (20:14 +0000)
commit9744be5e8952df4e983923cc88c8301bb967c216
treecd0ced049af382b29330823a97955faa5407aa0f
parente792a03d06b3f334725c025f930b700fb628b8ed
xen/gntdev: Fix the abuse of underlying struct page in DMA-buf import

[ Upstream commit 2d2db7d40254d5fb53b11ebd703cd1ed0c5de7a1 ]

DO NOT access the underlying struct page of an sg table exported
by DMA-buf in dmabuf_imp_to_refs(), this is not allowed.
Please see drivers/dma-buf/dma-buf.c:mangle_sg_table() for details.

Fortunately, here (for special Xen device) we can avoid using
pages and calculate gfns directly from dma addresses provided by
the sg table.

Suggested-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Link: https://lore.kernel.org/r/20240107103426.2038075-1-olekstysh@gmail.com
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/xen/gntdev-dmabuf.c