From: Andrzej Hajda <a.hajda@samsung.com>
To: Inki Dae <inki.dae@samsung.com>
Cc: Andrzej Hajda <a.hajda@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Joonyoung Shim <jy0922.shim@samsung.com>,
Seung-Woo Kim <sw0312.kim@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org (open list),
linux-samsung-soc@vger.kernel.org (moderated list:ARM/S5P EXYNOS
AR...)
Subject: [PATCH v3 17/17] drm/exynos/ipp: add file checks for ioctls
Date: Tue, 02 Sep 2014 14:56:21 +0200 [thread overview]
Message-ID: <1409662581-30357-1-git-send-email-a.hajda@samsung.com> (raw)
In-Reply-To: <1409216861-12452-18-git-send-email-a.hajda@samsung.com>
Process should not have access to ipp nodes created by another
process. The patch adds necessary checks.
It also simplifies lookup for command node.
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
v3:
- added file check from previous commit
- simplified c_node lookup
---
drivers/gpu/drm/exynos/exynos_drm_ipp.c | 69 +++++++++++----------------------
1 file changed, 22 insertions(+), 47 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index 9e9714a..4f36a9d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -318,44 +318,6 @@ static void ipp_print_property(struct drm_exynos_ipp_property *property,
sz->hsize, sz->vsize, config->flip, config->degree);
}
-static int ipp_find_and_set_property(struct drm_exynos_ipp_property *property)
-{
- struct exynos_drm_ippdrv *ippdrv;
- struct drm_exynos_ipp_cmd_node *c_node;
- u32 prop_id = property->prop_id;
-
- DRM_DEBUG_KMS("prop_id[%d]\n", prop_id);
-
- ippdrv = ipp_find_drv_by_handle(prop_id);
- if (IS_ERR(ippdrv)) {
- DRM_ERROR("failed to get ipp driver.\n");
- return -EINVAL;
- }
-
- /*
- * Find command node using command list in ippdrv.
- * when we find this command no using prop_id.
- * return property information set in this command node.
- */
- mutex_lock(&ippdrv->cmd_lock);
- list_for_each_entry(c_node, &ippdrv->cmd_list, list) {
- if ((c_node->property.prop_id == prop_id) &&
- (c_node->state == IPP_STATE_STOP)) {
- mutex_unlock(&ippdrv->cmd_lock);
- DRM_DEBUG_KMS("found cmd[%d]ippdrv[0x%x]\n",
- property->cmd, (int)ippdrv);
-
- c_node->property = *property;
- return 0;
- }
- }
- mutex_unlock(&ippdrv->cmd_lock);
-
- DRM_ERROR("failed to search property.\n");
-
- return -EINVAL;
-}
-
static struct drm_exynos_ipp_cmd_work *ipp_create_cmd_work(void)
{
struct drm_exynos_ipp_cmd_work *cmd_work;
@@ -391,6 +353,7 @@ int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
struct drm_exynos_ipp_property *property = data;
struct exynos_drm_ippdrv *ippdrv;
struct drm_exynos_ipp_cmd_node *c_node;
+ u32 prop_id;
int ret, i;
if (!ctx) {
@@ -403,6 +366,8 @@ int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
return -EINVAL;
}
+ prop_id = property->prop_id;
+
/*
* This is log print for user application property.
* user application set various property.
@@ -411,14 +376,24 @@ int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
ipp_print_property(property, i);
/*
- * set property ioctl generated new prop_id.
- * but in this case already asigned prop_id using old set property.
- * e.g PAUSE state. this case supports find current prop_id and use it
- * instead of allocation.
+ * In case prop_id is not zero try to set existing property.
*/
- if (property->prop_id) {
- DRM_DEBUG_KMS("prop_id[%d]\n", property->prop_id);
- return ipp_find_and_set_property(property);
+ if (prop_id) {
+ c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock, prop_id);
+
+ if (!c_node || c_node->filp != file) {
+ DRM_DEBUG_KMS("prop_id[%d] not found\n", prop_id);
+ return -EINVAL;
+ }
+
+ if (c_node->state != IPP_STATE_STOP) {
+ DRM_DEBUG_KMS("prop_id[%d] not stopped\n", prop_id);
+ return -EINVAL;
+ }
+
+ c_node->property = *property;
+
+ return 0;
}
/* find ipp driver using ipp id */
@@ -897,7 +872,7 @@ int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void *data,
/* find command node */
c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock,
qbuf->prop_id);
- if (!c_node) {
+ if (!c_node || c_node->filp != file) {
DRM_ERROR("failed to get command node.\n");
return -ENODEV;
}
@@ -1032,7 +1007,7 @@ int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void *data,
c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock,
cmd_ctrl->prop_id);
- if (!c_node) {
+ if (!c_node || c_node->filp != file) {
DRM_ERROR("invalid command node list.\n");
return -ENODEV;
}
--
1.9.1
next prev parent reply other threads:[~2014-09-02 12:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-28 9:07 [PATCH v2 00/17] drm/exynos/ipp: image post processing fixes and improvements, part four Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 01/17] drm/exynos/ipp: remove fake pm callbacks Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 02/17] drm/exynos/ipp: cancel works before command node clean Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 03/17] drm/exynos/ipp: move file reference from memory to command node Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 04/17] drm/exynos/ipp: remove only related commands on file close Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 05/17] drm/exynos/ipp: remove unused field in command node Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 06/17] drm/exynos/ipp: free partially allocated resources on error Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 07/17] drm/exynos/ipp: move nodes cleaning to separate function Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 08/17] drm/exynos/ipp: clean memory nodes on command node cleaning Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 09/17] drm/exynos/ipp: replace work_struct casting with better constructs Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 10/17] drm/exynos/ipp: stop hardware before freeing memory Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 11/17] drm/exynos/ipp: remove events during command cleaning Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 12/17] drm/exynos/fimc: avoid clearing overflow bits Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 13/17] drm/exynos/fimc: do not enable fimc twice Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 14/17] drm/exynos/fimc: simplify buffer queuing Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 15/17] drm/exynos/fimc: fix source buffer registers Andrzej Hajda
2014-08-28 9:07 ` [PATCH v2 16/17] drm/exynos/ipp: remove file argument from node related functions Andrzej Hajda
2014-08-29 7:03 ` Joonyoung Shim
2014-09-02 12:55 ` [PATCH v3 " Andrzej Hajda
2014-09-03 1:42 ` Joonyoung Shim
2014-08-28 9:07 ` [PATCH v2 17/17] drm/exynos/ipp: add file checks for ioctls Andrzej Hajda
2014-08-29 7:11 ` Joonyoung Shim
2014-09-02 12:56 ` Andrzej Hajda [this message]
2014-09-11 12:50 ` [PATCH v2 00/17] drm/exynos/ipp: image post processing fixes and improvements, part four Inki Dae
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=1409662581-30357-1-git-send-email-a.hajda@samsung.com \
--to=a.hajda@samsung.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=inki.dae@samsung.com \
--cc=jy0922.shim@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=sw0312.kim@samsung.com \
/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®