Commit aa3f9989 authored by Dmitry Osipenko's avatar Dmitry Osipenko

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: default avatarDaniel Vetter <daniel@ffwll.ch>
Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221110201349.351294-4-dmitry.osipenko@collabora.com
parent 39ce2529
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <linux/cred.h> #include <linux/cred.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/dma-buf.h> #include <linux/dma-buf.h>
#include <linux/dma-resv.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -49,6 +50,8 @@ static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma) ...@@ -49,6 +50,8 @@ static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma)
{ {
struct udmabuf *ubuf = buf->priv; struct udmabuf *ubuf = buf->priv;
dma_resv_assert_held(buf->resv);
if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0) if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment