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: Tomasz Figa <tfiga@chromium.org>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221110201349.351294-6-dmitry.osipenko@collabora.com
  */
 
 #include <linux/dma-buf.h>
+#include <linux/dma-resv.h>
 #include <linux/module.h>
 #include <linux/refcount.h>
 #include <linux/scatterlist.h>
 static int vb2_dc_dmabuf_ops_mmap(struct dma_buf *dbuf,
        struct vm_area_struct *vma)
 {
+       dma_resv_assert_held(dbuf->resv);
+
        return vb2_dc_mmap(dbuf->priv, vma);
 }
 
 
  * the Free Software Foundation.
  */
 
+#include <linux/dma-resv.h>
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/refcount.h>
 static int vb2_dma_sg_dmabuf_ops_mmap(struct dma_buf *dbuf,
        struct vm_area_struct *vma)
 {
+       dma_resv_assert_held(dbuf->resv);
+
        return vb2_dma_sg_mmap(dbuf->priv, vma);
 }
 
 
  * the Free Software Foundation.
  */
 
+#include <linux/dma-resv.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/mm.h>
 static int vb2_vmalloc_dmabuf_ops_mmap(struct dma_buf *dbuf,
        struct vm_area_struct *vma)
 {
+       dma_resv_assert_held(dbuf->resv);
+
        return vb2_vmalloc_mmap(dbuf->priv, vma);
 }