All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: "Rebecca N. Palmer" <rebecca_palmer@zoho.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/i915: Fix possible security hole in command parsing
Date: Fri, 08 May 2015 17:04:48 +0300	[thread overview]
Message-ID: <87d22bgo73.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <554CB99A.3090501@zoho.com>

"Rebecca N. Palmer" <rebecca_palmer@zoho.com> writes:

Hi,

>> where cmdparser is disabled, batch_obj is
>> left dangling
> Sorry!  Fixed now.
>

There is absolutely nothing to be sorry about.

> This version also brings exec_start = 0 inside this check, as it
> appears to be there because the copying (i915_cmd_parser.c:1054)
> removes any offset the original might have had.
>
> When tested on next-20150508 (675b3fb), it passed my checks
> (libva tests, vlc video, glxgears, beignet tests), and didn't
> show the "missing window title bar" problem [0-1] in 3 attempts,
> but given the intermittent nature of that I can't be sure.
>
> I still can't give useful i-g-t results, as it works on 3.16
> but reports "GPU HANG" for most tests on 4.0 and (both patched and
> unpatched) next (scripts/run-tests.sh at the recovery-mode
> (single-user-mode) prompt, both i-g-t 1.10 and latest git).
>
> [0] http://lists.freedesktop.org/archives/intel-gfx/2015-May/065705.html
> [1] http://lists.freedesktop.org/archives/intel-gfx/2015-May/065906.html
>
> ---
>
> i915_gem_execbuffer_parse returns the original batch_obj on batches
> it can't check (currently, chained batches).  Don't set the secure
> bit in this case.
>
> v2 (thanks to Mika Kuoppala):
> Don't leave batch_obj unset when the parser is not run.
> Only do exec_start = 0 on parsed batches.
> Add comments.
>
> Signed-off-by: Rebecca Palmer <rebecca_palmer@zoho.com>
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> index 7ab63d9..2fb6dc1 100644
> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> @@ -1540,28 +1540,38 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
>  	}
>  
>  	if (i915_needs_cmd_parser(ring) && args->batch_len) {
> -		batch_obj = i915_gem_execbuffer_parse(ring,
> +		struct drm_i915_gem_object *parsed_batch_obj;
> +
> +		parsed_batch_obj = i915_gem_execbuffer_parse(ring,
>  						      &shadow_exec_entry,
>  						      eb,
>  						      batch_obj,
>  						      args->batch_start_offset,
>  						      args->batch_len,
>  						      file->is_master);
> -		if (IS_ERR(batch_obj)) {
> -			ret = PTR_ERR(batch_obj);
> +		if (IS_ERR(parsed_batch_obj)) {
> +			/* Batch rejected by parser, or an error
> occurred */

This comment should be omitted as the rejection part is not
valid in here and the error part is redudant. Daniel can squash it while
applying I think.

For a first patch, stellar work!

Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>

> +			ret = PTR_ERR(parsed_batch_obj);
>  			goto err;
>  		}
>  
> -		/*
> -		 * Set the DISPATCH_SECURE bit to remove the NON_SECURE
> -		 * bit from MI_BATCH_BUFFER_START commands issued in the
> -		 * dispatch_execbuffer implementations. We specifically
> -		 * don't want that set when the command parser is
> -		 * enabled.
> -		 */
> -		dispatch_flags |= I915_DISPATCH_SECURE;
> -
> -		exec_start = 0;
> +		/* parsed_batch_obj == batch_obj means batch not fully parsed:
> +		 * accept, but don't promote to secure */
> +
> +		if (parsed_batch_obj != batch_obj) {
> +			/*
> +			 * Batch parsed and accepted:
> +			 *
> +			 * Set the DISPATCH_SECURE bit to remove the NON_SECURE
> +			 * bit from MI_BATCH_BUFFER_START commands issued in
> +			 * the dispatch_execbuffer implementations. We
> +			 * specifically don't want that set on batches the
> +			 * command parser has accepted.
> +			 */
> +			dispatch_flags |= I915_DISPATCH_SECURE;
> +			exec_start = 0;
> +			batch_obj = parsed_batch_obj;
> +		}
>  	}
>  
>  	batch_obj->base.pending_read_domains |= I915_GEM_DOMAIN_COMMAND;
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-05-08 14:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30 11:32 [PATCH] drm/i915: Possible security hole in command parsing Rebecca N. Palmer
2015-05-01 19:13 ` Rebecca N. Palmer
2015-05-05 21:39   ` Rebecca N. Palmer
2015-06-05  0:29     ` Kees Cook
2015-06-05  8:04       ` Rebecca N. Palmer
2015-05-08  9:31 ` [PATCH] " Mika Kuoppala
2015-05-08 11:24 ` Daniel Vetter
2015-05-08 13:26   ` [PATCH v2] drm/i915: Fix possible " Rebecca N. Palmer
2015-05-08 14:04     ` Mika Kuoppala [this message]
2015-05-08 14:25       ` Daniel Vetter
2015-05-08 16:51         ` [PATCH for 4.1] drm/i915: Don't clear exec_start if batch was not copied Rebecca N. Palmer

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=87d22bgo73.fsf@gaia.fi.intel.com \
    --to=mika.kuoppala@linux.intel.com \
    --cc=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rebecca_palmer@zoho.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.