From: Dmitry Osipenko Date: Thu, 10 Nov 2022 20:13:49 +0000 (+0300) Subject: fastrpc: Assert held reservation lock for dma-buf mmapping X-Git-Tag: v6.2-rc1~124^2~16^2~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=265751a513adfec50bcb7354fc287a9bd3a62129;p=thirdparty%2Flinux.git fastrpc: Assert held reservation lock for dma-buf mmapping When userspace mmaps dma-buf's fd, the dma-buf reservation lock must be held. Add locking sanity check to the dma-buf mmaping callback to ensure that the locking assumption won't regress in the future. Suggested-by: Daniel Vetter Signed-off-by: Dmitry Osipenko Acked-by: Christian König Link: https://patchwork.freedesktop.org/patch/msgid/20221110201349.351294-7-dmitry.osipenko@collabora.com --- diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 1ad5808655254..0f467a71b0698 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -682,6 +683,8 @@ static int fastrpc_mmap(struct dma_buf *dmabuf, struct fastrpc_buf *buf = dmabuf->priv; size_t size = vma->vm_end - vma->vm_start; + dma_resv_assert_held(dmabuf->resv); + return dma_mmap_coherent(buf->dev, vma, buf->virt, FASTRPC_PHYS(buf->phys), size); }