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 v3 05/20] drm/tegra: Check syncpoint ID in the 'submit' IOCTL
Date: Thu, 15 Jun 2017 02:18:28 +0300	[thread overview]
Message-ID: <a1cb57375c6b67a32b5b47659ca56e506de1b8a3.1497480756.git.digetx@gmail.com> (raw)
In-Reply-To: <cover.1497480751.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
In-Reply-To: <cover.1497480751.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

In case of invalid syncpoint ID, the host1x_syncpt_get() returns NULL and
none of its users perform a check of the returned pointer later. Let's bail
out until it's too late.

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 | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index b90ed2cd32ce..e999391aedc9 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -393,6 +393,8 @@ int tegra_drm_submit(struct tegra_drm_context *context,
 	struct drm_tegra_waitchk __user *waitchks =
 		(void __user *)(uintptr_t)args->waitchks;
 	struct drm_tegra_syncpt syncpt;
+	struct host1x *host1x = dev_get_drvdata(drm->dev->parent);
+	struct host1x_syncpt *sp;
 	struct host1x_job *job;
 	int err;
 
@@ -522,6 +524,13 @@ int tegra_drm_submit(struct tegra_drm_context *context,
 		goto fail;
 	}
 
+	/* check whether syncpoint ID is valid */
+	sp = host1x_syncpt_get(host1x, syncpt.id);
+	if (!sp) {
+		err = -ENOENT;
+		goto fail;
+	}
+
 	job->is_addr_reg = context->client->ops->is_addr_reg;
 	job->syncpt_incrs = syncpt.incrs;
 	job->syncpt_id = syncpt.id;
-- 
2.13.0

  parent reply	other threads:[~2017-06-14 23:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14 23:18 [PATCH v3 00/20] Tegra DRM fixes Dmitry Osipenko
     [not found] ` <cover.1497480751.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-14 23:18   ` [PATCH v3 01/20] drm/tegra: Fix lockup on a use of staging API Dmitry Osipenko
     [not found]     ` <7b70a506a9d2355ea6ff19a8c4f4d726b67719b3.1497480754.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-15 12:11       ` Thierry Reding
2017-06-14 23:18   ` [PATCH v3 02/20] drm/tegra: Correct idr_alloc() minimum id Dmitry Osipenko
     [not found]     ` <9c19a44219acd988e678cf9abe21363911184625.1497480754.git.digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-15 12:13       ` Thierry Reding
2017-06-14 23:18   ` [PATCH v3 03/20] drm/tegra: Check for malformed offsets and sizes in the 'submit' IOCTL Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 04/20] drm/tegra: Correct copying of waitchecks and disable them " Dmitry Osipenko
2017-06-14 23:18   ` Dmitry Osipenko [this message]
2017-06-14 23:18   ` [PATCH v3 06/20] drm/tegra: dc: Avoid reset asserts on Tegra20 Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 07/20] drm/tegra: dc: Apply clipping to the plane Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 08/20] drm/tegra: dc: Disable plane if it is invisible Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 09/20] gpu: host1x: Initialize firewall class to the jobs one Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 10/20] gpu: host1x: Correct host1x_job_pin() error handling Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 11/20] gpu: host1x: Do not leak BO's phys address to userspace Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 12/20] gpu: host1x: Forbid relocation address shifting in the firewall Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 13/20] gpu: host1x: Forbid RESTART opcode " Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 14/20] gpu: host1x: Forbid unrelated SETCLASS " Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 15/20] gpu: host1x: Correct swapped arguments in the is_addr_reg() definition Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 16/20] gpu: host1x: Check waits in the firewall Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 17/20] gpu: host1x: Remove unused 'struct host1x_cmdbuf' Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 18/20] gpu: host1x: Remove unused host1x_cdma_stop() definition Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 19/20] gpu: host1x: Refactor channel allocation code Dmitry Osipenko
2017-06-14 23:18   ` [PATCH v3 20/20] gpu: host1x: At first try a non-blocking allocation for the gather copy Dmitry Osipenko
2017-06-15 13:33   ` [PATCH v3 00/20] Tegra DRM fixes Thierry Reding

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=a1cb57375c6b67a32b5b47659ca56e506de1b8a3.1497480756.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).