From: Dmitry Osipenko Date: Thu, 10 Nov 2022 20:13:46 +0000 (+0300) Subject: udmabuf: Assert held reservation lock for dma-buf mmapping X-Git-Tag: v6.6.17~3937^2~23^2~1334 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aa3f99896443ea26e115f08757008d14430876f9;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Dmitry Osipenko Acked-by: Christian König Link: https://patchwork.freedesktop.org/patch/msgid/20221110201349.351294-4-dmitry.osipenko@collabora.com --- 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 #include #include +#include #include #include #include @@ -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;