mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org,
	Dmitry Osipenko <dmitry.osipenko@collabora.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Subject: [PATCH 01/11] misc: fastrpc: Assert held reservation lock for dma-buf mmapping
Date: Thu, 24 Nov 2022 17:51:15 +0000	[thread overview]
Message-ID: <20221124175125.418702-2-srinivas.kandagatla@linaro.org> (raw)
In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org>

From: Dmitry Osipenko <dmitry.osipenko@collabora.com>

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>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/misc/fastrpc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 80811e852d8f..c6b9ddaa698b 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -6,6 +6,7 @@
 #include <linux/device.h>
 #include <linux/dma-buf.h>
 #include <linux/dma-mapping.h>
+#include <linux/dma-resv.h>
 #include <linux/idr.h>
 #include <linux/list.h>
 #include <linux/miscdevice.h>
@@ -692,6 +693,8 @@ static int fastrpc_mmap(struct dma_buf *dmabuf,
 	struct fastrpc_buf *buf = dmabuf->priv;
 	size_t size = vma->vm_end - vma->vm_start;
 
+	dma_resv_assert_held(dmabuf->resv);
+
 	return dma_mmap_coherent(buf->dev, vma, buf->virt,
 				 FASTRPC_PHYS(buf->phys), size);
 }
-- 
2.25.1


  reply	other threads:[~2022-11-24 17:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 17:51 [PATCH 00/11] misc: fastrpc: patches for 6.2 Srinivas Kandagatla
2022-11-24 17:51 ` Srinivas Kandagatla [this message]
2022-11-24 18:03   ` [PATCH 01/11] misc: fastrpc: Assert held reservation lock for dma-buf mmapping Dmitry Osipenko
2022-11-25  6:58     ` Srinivas Kandagatla
2022-11-24 17:51 ` [PATCH 02/11] dt-bindings: misc: qcom,fastrpc: increase allowed iommus entries Srinivas Kandagatla
2022-11-24 17:51 ` [PATCH 03/11] misc: fastrpc: Rename audio protection domain to root Srinivas Kandagatla
2022-11-24 17:51 ` [PATCH 04/11] misc: fastrpc: Add reserved mem support Srinivas Kandagatla
2022-11-24 17:51 ` [PATCH 05/11] misc: fastrpc: Add fastrpc_remote_heap_alloc Srinivas Kandagatla
2022-11-24 17:51 ` [PATCH 06/11] misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail Srinivas Kandagatla
2022-11-24 17:51 ` [PATCH 07/11] misc: fastrpc: Rework fastrpc_req_munmap Srinivas Kandagatla
2022-11-24 17:51 ` [PATCH 08/11] misc: fastrpc: Add support for audiopd Srinivas Kandagatla
2022-11-24 17:51 ` [PATCH 09/11] misc: fastrpc: Safekeep mmaps on interrupted invoke Srinivas Kandagatla
2022-11-24 17:51 ` [PATCH 10/11] misc: fastrpc: Add mmap request assigning for static PD pool Srinivas Kandagatla
2022-11-24 17:51 ` [PATCH 11/11] misc: fastrpc: Add dma_mask to fastrpc_channel_ctx Srinivas Kandagatla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221124175125.418702-2-srinivas.kandagatla@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=daniel@ffwll.ch \
    --cc=dmitry.osipenko@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®