aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>2020-08-13 09:21:09 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-08-19 08:15:07 +0200
commite4ca0185dc1c18eb998e94c8dfa2757a85f67aa5 (patch)
tree2acd623ce4644980d8dbae7c4faf72342cc64575
parent0fc9dd00afe7f82ff6692387c6a0088bb2c9f067 (diff)
downloadlinux-yocto-e4ca0185dc1c18eb998e94c8dfa2757a85f67aa5.tar.gz
linux-yocto-e4ca0185dc1c18eb998e94c8dfa2757a85f67aa5.tar.bz2
linux-yocto-e4ca0185dc1c18eb998e94c8dfa2757a85f67aa5.zip
xen/gntdev: Fix dmabuf import with non-zero sgt offset
commit 5fa4e6f1c2d8c9a4e47e1931b42893172d388f2b upstream. It is possible that the scatter-gather table during dmabuf import has non-zero offset of the data, but user-space doesn't expect that. Fix this by failing the import, so user-space doesn't access wrong data. Fixes: bf8dc55b1358 ("xen/gntdev: Implement dma-buf import functionality") Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Acked-by: Juergen Gross <jgross@suse.com> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20200813062113.11030-2-andr2000@gmail.com Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/xen/gntdev-dmabuf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c
index d97fcfc5e558..f6589563ff71 100644
--- a/drivers/xen/gntdev-dmabuf.c
+++ b/drivers/xen/gntdev-dmabuf.c
@@ -641,6 +641,14 @@ dmabuf_imp_to_refs(struct gntdev_dmabuf_priv *priv, struct device *dev,
goto fail_detach;
}
+ /* Check that we have zero offset. */
+ if (sgt->sgl->offset) {
+ ret = ERR_PTR(-EINVAL);
+ pr_debug("DMA buffer has %d bytes offset, user-space expects 0\n",
+ sgt->sgl->offset);
+ goto fail_unmap;
+ }
+
/* Check number of pages that imported buffer has. */
if (attach->dmabuf->size != gntdev_dmabuf->nr_pages << PAGE_SHIFT) {
ret = ERR_PTR(-EINVAL);