diff options
author | Dmitry Osipenko <dmitry.osipenko@collabora.com> | 2022-11-10 23:13:47 +0300 |
---|---|---|
committer | Dmitry Osipenko <dmitry.osipenko@collabora.com> | 2022-11-11 23:49:51 +0300 |
commit | 27f3733a104950169797407fea330a2e1d42f16b (patch) | |
tree | 7c6f1f640cb5cf8c86939d5d32b2453e87409cb8 /drivers/dma-buf/heaps/cma_heap.c | |
parent | aa3f99896443ea26e115f08757008d14430876f9 (diff) |
dma-buf/heaps: 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 checks to the dma-buf mmaping callbacks to ensure
that the locking assumptions won't regress in the future.
Suggested-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221110201349.351294-5-dmitry.osipenko@collabora.com
Diffstat (limited to 'drivers/dma-buf/heaps/cma_heap.c')
-rw-r--r-- | drivers/dma-buf/heaps/cma_heap.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 28fb04eccdd0..1131fb943992 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -13,6 +13,7 @@ #include <linux/dma-buf.h> #include <linux/dma-heap.h> #include <linux/dma-map-ops.h> +#include <linux/dma-resv.h> #include <linux/err.h> #include <linux/highmem.h> #include <linux/io.h> @@ -182,6 +183,8 @@ static int cma_heap_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) { struct cma_heap_buffer *buffer = dmabuf->priv; + dma_resv_assert_held(dmabuf->resv); + if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0) return -EINVAL; |