mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
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
This commit is contained in:
parent
39ce252918
commit
aa3f998964
@ -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)
|
|||||||
{
|
{
|
||||||
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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user