[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200901151002.527351535@linuxfoundation.org>
Date: Tue, 1 Sep 2020 17:11:20 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Nicolai Stange <nstange@...e.de>,
Miroslav Benes <mbenes@...e.cz>, Takashi Iwai <tiwai@...e.de>,
Tyler Hicks <tyhicks@...onical.com>,
Jon Bloomfield <jon.bloomfield@...el.com>,
Chris Wilson <chris.p.wilson@...el.com>,
Mika Kuoppala <mika.kuoppala@...ux.intel.com>,
Chris Wilson <chris@...is-wilson.co.uk>,
Jani Nikula <jani.nikula@...el.com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 5.4 200/214] drm/i915: Fix cmd parser desc matching with masks
From: Mika Kuoppala <mika.kuoppala@...ux.intel.com>
[ Upstream commit e5f10d6385cda083037915c12b130887c8831d2b ]
Our variety of defined gpu commands have the actual
command id field and possibly length and flags applied.
We did start to apply the mask during initialization of
the cmd descriptors but forgot to also apply it on comparisons.
Fix comparisons in order to properly deny access with
associated commands.
v2: fix lri with correct mask (Chris)
Reported-by: Nicolai Stange <nstange@...e.de>
Cc: stable@...r.kernel.org # v5.4+
Cc: Miroslav Benes <mbenes@...e.cz>
Cc: Takashi Iwai <tiwai@...e.de>
Cc: Tyler Hicks <tyhicks@...onical.com>
Cc: Jon Bloomfield <jon.bloomfield@...el.com>
Cc: Chris Wilson <chris.p.wilson@...el.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala@...ux.intel.com>
Reviewed-by: Chris Wilson <chris@...is-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200817195926.12671-1-mika.kuoppala@linux.intel.com
(cherry picked from commit 3b4efa148da36f158cce3f662e831af2834b8e0f)
Signed-off-by: Jani Nikula <jani.nikula@...el.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/gpu/drm/i915/i915_cmd_parser.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c
index 21417ac8e878e..a9a69760c18d0 100644
--- a/drivers/gpu/drm/i915/i915_cmd_parser.c
+++ b/drivers/gpu/drm/i915/i915_cmd_parser.c
@@ -1207,6 +1207,12 @@ static u32 *copy_batch(struct drm_i915_gem_object *dst_obj,
return dst;
}
+static inline bool cmd_desc_is(const struct drm_i915_cmd_descriptor * const desc,
+ const u32 cmd)
+{
+ return desc->cmd.value == (cmd & desc->cmd.mask);
+}
+
static bool check_cmd(const struct intel_engine_cs *engine,
const struct drm_i915_cmd_descriptor *desc,
const u32 *cmd, u32 length)
@@ -1245,19 +1251,19 @@ static bool check_cmd(const struct intel_engine_cs *engine,
* allowed mask/value pair given in the whitelist entry.
*/
if (reg->mask) {
- if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+ if (cmd_desc_is(desc, MI_LOAD_REGISTER_MEM)) {
DRM_DEBUG_DRIVER("CMD: Rejected LRM to masked register 0x%08X\n",
reg_addr);
return false;
}
- if (desc->cmd.value == MI_LOAD_REGISTER_REG) {
+ if (cmd_desc_is(desc, MI_LOAD_REGISTER_REG)) {
DRM_DEBUG_DRIVER("CMD: Rejected LRR to masked register 0x%08X\n",
reg_addr);
return false;
}
- if (desc->cmd.value == MI_LOAD_REGISTER_IMM(1) &&
+ if (cmd_desc_is(desc, MI_LOAD_REGISTER_IMM(1)) &&
(offset + 2 > length ||
(cmd[offset + 1] & reg->mask) != reg->value)) {
DRM_DEBUG_DRIVER("CMD: Rejected LRI to masked register 0x%08X\n",
@@ -1488,7 +1494,7 @@ int intel_engine_cmd_parser(struct i915_gem_context *ctx,
goto err;
}
- if (desc->cmd.value == MI_BATCH_BUFFER_START) {
+ if (cmd_desc_is(desc, MI_BATCH_BUFFER_START)) {
ret = check_bbstart(ctx, cmd, offset, length,
batch_len, batch_start,
shadow_batch_start);
--
2.25.1
Powered by blists - more mailing lists