linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Thierry Reding
	<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Mikko Perttunen <cyndis-/1wQRMveznE@public.gmane.org>,
	Erik Faye-Lund
	<kusmabite-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	DRI Development
	<dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: [PATCH v2 01/22] drm/tegra: Fix lockup on a use of staging API
Date: Wed, 14 Jun 2017 02:15:40 +0300	[thread overview]
Message-ID: <d2616b82a1728d0953e84489cde40364999719f0.1497394243.git.digetx@gmail.com> (raw)
In-Reply-To: <cover.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
In-Reply-To: <cover.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Commit bdd2f9cd ("Don't leak kernel pointer to userspace") added a mutex
around staging IOCTL's, some of those mutexes are taken twice.

Fixes: bdd2f9cd10eb ("drm/tegra: Don't leak kernel pointer to userspace")
Signed-off-by: Dmitry Osipenko <digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reviewed-by: Mikko Perttunen <mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/gpu/drm/tegra/drm.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 51c48a8e00ec..b49d32a89f40 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -451,18 +451,6 @@ int tegra_drm_submit(struct tegra_drm_context *context,
 
 
 #ifdef CONFIG_DRM_TEGRA_STAGING
-static struct tegra_drm_context *
-tegra_drm_file_get_context(struct tegra_drm_file *file, u32 id)
-{
-	struct tegra_drm_context *context;
-
-	mutex_lock(&file->lock);
-	context = idr_find(&file->contexts, id);
-	mutex_unlock(&file->lock);
-
-	return context;
-}
-
 static int tegra_gem_create(struct drm_device *drm, void *data,
 			    struct drm_file *file)
 {
@@ -606,7 +594,7 @@ static int tegra_close_channel(struct drm_device *drm, void *data,
 
 	mutex_lock(&fpriv->lock);
 
-	context = tegra_drm_file_get_context(fpriv, args->context);
+	context = idr_find(&fpriv->contexts, args->context);
 	if (!context) {
 		err = -EINVAL;
 		goto unlock;
@@ -631,7 +619,7 @@ static int tegra_get_syncpt(struct drm_device *drm, void *data,
 
 	mutex_lock(&fpriv->lock);
 
-	context = tegra_drm_file_get_context(fpriv, args->context);
+	context = idr_find(&fpriv->contexts, args->context);
 	if (!context) {
 		err = -ENODEV;
 		goto unlock;
@@ -660,7 +648,7 @@ static int tegra_submit(struct drm_device *drm, void *data,
 
 	mutex_lock(&fpriv->lock);
 
-	context = tegra_drm_file_get_context(fpriv, args->context);
+	context = idr_find(&fpriv->contexts, args->context);
 	if (!context) {
 		err = -ENODEV;
 		goto unlock;
@@ -685,7 +673,7 @@ static int tegra_get_syncpt_base(struct drm_device *drm, void *data,
 
 	mutex_lock(&fpriv->lock);
 
-	context = tegra_drm_file_get_context(fpriv, args->context);
+	context = idr_find(&fpriv->contexts, args->context);
 	if (!context) {
 		err = -ENODEV;
 		goto unlock;
-- 
2.13.0

  parent reply	other threads:[~2017-06-13 23:15 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13 23:15 [PATCH v2 00/22] Tegra DRM fixes Dmitry Osipenko
     [not found] ` <cover.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-13 23:15   ` Dmitry Osipenko [this message]
     [not found]     ` <d2616b82a1728d0953e84489cde40364999719f0.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14  7:09       ` [PATCH v2 01/22] drm/tegra: Fix lockup on a use of staging API Erik Faye-Lund
2017-06-13 23:15   ` [PATCH v2 02/22] drm/tegra: Correct idr_alloc() minimum id Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 03/22] drm/tegra: Check for malformed offsets and sizes in the 'submit' IOCTL Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 04/22] drm/tegra: Correct copying of waitchecks and disable them " Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 05/22] drm/tegra: Check syncpoint ID " Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 06/22] drm/tegra: dc: Avoid reset asserts on Tegra20 Dmitry Osipenko
     [not found]     ` <1c7b0c7bf713401073d648f9f228fa152c094a5a.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14  7:13       ` Erik Faye-Lund
2017-06-13 23:15   ` [PATCH v2 07/22] drm/tegra: dc: Apply clipping to the plane Dmitry Osipenko
     [not found]     ` <7adbe0c6e67115fa4fd201026533b7cb97fc44d2.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14  7:20       ` Erik Faye-Lund
2017-06-13 23:15   ` [PATCH v2 08/22] drm/tegra: dc: Disable plane if it is invisible Dmitry Osipenko
2017-06-14  7:21     ` Erik Faye-Lund
2017-06-13 23:15   ` [PATCH v2 09/22] drm/tegra: Don't use IOMMU on Tegra20 Dmitry Osipenko
     [not found]     ` <d707bd34e268f9d8fb29bf510a9f17e5f943a635.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14  7:39       ` Erik Faye-Lund
     [not found]         ` <CABPQNSbMQMrahcvWnczywLDYVU0=Ns=FB6Yseisk-5L_8Y=rpQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-14 10:22           ` Dmitry Osipenko
     [not found]             ` <16be88ba-808d-4d3e-533b-7dce4a2765e7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14 22:24               ` Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 10/22] Revert "iommu/tegra: gart: Do not register with bus" Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 11/22] gpu: host1x: Initialize firewall class to the jobs one Dmitry Osipenko
     [not found]     ` <8c0a2417584ce51b716f2c286027bcb18fceda56.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14  7:41       ` Erik Faye-Lund
2017-06-13 23:15   ` [PATCH v2 12/22] gpu: host1x: Correct host1x_job_pin() error handling Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 13/22] gpu: host1x: Do not leak BO's phys address to userspace Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 14/22] gpu: host1x: Forbid relocation address shifting in the firewall Dmitry Osipenko
     [not found]     ` <5e6f06d3e57db40c1c4947282ef7336369c3360f.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14  6:50       ` Mikko Perttunen
     [not found]         ` <6db57dae-0de7-45a5-2ed5-1ebd84577742-/1wQRMveznE@public.gmane.org>
2017-06-14  9:06           ` Dmitry Osipenko
     [not found]             ` <3d723511-45f2-3c80-58fe-c9050624ac94-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14 11:47               ` Mikko Perttunen
     [not found]                 ` <bc4d8ea3-0fd7-85ad-be08-bc869d0e89a6-/1wQRMveznE@public.gmane.org>
2017-06-14 14:49                   ` Dmitry Osipenko
     [not found]                     ` <a18ec3c6-0fa1-4daa-3db4-c81124424cec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14 14:59                       ` Mikko Perttunen
2017-06-13 23:15   ` [PATCH v2 15/22] gpu: host1x: Forbid RESTART opcode " Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 16/22] gpu: host1x: Forbid unrelated SETCLASS " Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 17/22] gpu: host1x: Correct swapped arguments in the is_addr_reg() definition Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 18/22] gpu: host1x: Check waits in the firewall Dmitry Osipenko
     [not found]     ` <bd57829e74c6554c46ab761d013e6d9d3c39b693.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14  7:47       ` Erik Faye-Lund
2017-06-13 23:15   ` [PATCH v2 19/22] gpu: host1x: Remove unused 'struct host1x_cmdbuf' Dmitry Osipenko
2017-06-13 23:15   ` [PATCH v2 20/22] gpu: host1x: Remove unused host1x_cdma_stop() definition Dmitry Osipenko
2017-06-13 23:16   ` [PATCH v2 21/22] gpu: host1x: Refactor channel allocation code Dmitry Osipenko
2017-06-13 23:16   ` [PATCH v2 22/22] gpu: host1x: At first try a non-blocking allocation for the gather copy Dmitry Osipenko
     [not found]     ` <036615566011ab4d52190439a12d943df9e704ef.1497394243.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14  7:56       ` Erik Faye-Lund
     [not found]         ` <CABPQNSZ8f8QqW4fJYCGfgf3q0pTyQ7NbS_=64x39kvrNDSyhdw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-14  8:32           ` Dmitry Osipenko
2017-06-14  8:44             ` Erik Faye-Lund

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=d2616b82a1728d0953e84489cde40364999719f0.1497394243.git.digetx@gmail.com \
    --to=digetx-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=cyndis-/1wQRMveznE@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=kusmabite-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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;
as well as URLs for NNTP newsgroup(s).