diff options
author | Dmitry Osipenko <dmitry.osipenko@collabora.com> | 2022-11-10 21:13:46 +0100 |
---|---|---|
committer | Dmitry Osipenko <dmitry.osipenko@collabora.com> | 2022-11-11 21:49:50 +0100 |
commit | aa3f99896443ea26e115f08757008d14430876f9 (patch) | |
tree | 096a598843768f8afc75a7cae5c40b959bb3e234 /drivers/dma-buf/udmabuf.c | |
parent | drm: Assert held reservation lock for dma-buf mmapping (diff) | |
download | linux-aa3f99896443ea26e115f08757008d14430876f9.tar.xz linux-aa3f99896443ea26e115f08757008d14430876f9.zip |
udmabuf: 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 <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-4-dmitry.osipenko@collabora.com
Diffstat (limited to 'drivers/dma-buf/udmabuf.c')
-rw-r--r-- | drivers/dma-buf/udmabuf.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 2bcdb935a3ac..283816fbd72f 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/drivers/dma-buf/udmabuf.c @@ -2,6 +2,7 @@ #include <linux/cred.h> #include <linux/device.h> #include <linux/dma-buf.h> +#include <linux/dma-resv.h> #include <linux/highmem.h> #include <linux/init.h> #include <linux/kernel.h> @@ -49,6 +50,8 @@ static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma) { struct udmabuf *ubuf = buf->priv; + dma_resv_assert_held(buf->resv); + if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0) return -EINVAL; |