Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nirmoy Das <nirmoy.das@intel.com>
To: Andrzej Hajda <andrzej.hajda@intel.com>,
	<intel-gfx@lists.freedesktop.org>
Cc: Chris Wilson <chris.p.wilson@intel.com>
Subject: Re: [Intel-gfx] [PATCH] drm/i915: do not dereference dangling engine pointer on fence release
Date: Mon, 5 Jun 2023 18:58:23 +0200	[thread overview]
Message-ID: <8f1a3827-5dee-628a-e278-d3fdd8e0a557@intel.com> (raw)
In-Reply-To: <20230605164840.1234582-1-andrzej.hajda@intel.com>

Hi Andrzej,

On 6/5/2023 6:48 PM, Andrzej Hajda wrote:
> rq->engine can be a dangling pointer if rq->execution_mask has more than
> one bit set, ie it could be already freed virtual engine. Changing check
> order prevents dereferncing it in intel_engine_is_virtual(rq->engine).
> Full description of possible scenarios at the inline comment before
> the change.


I came to the same conclusion but Chris mentioned "you create a guc 
virtual engine with just one bit in execution_mask" :)

Suggestion from Chris was to have "guc virtual bit" in there or 
"eliminate the single engine guc virtuals".


Regards,

Nirmoy

> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7926
> Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_request.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index 630a732aaecca8..8775952f5c1bbd 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -166,8 +166,8 @@ static void i915_fence_release(struct dma_fence *fence)
>   	 * know that if the rq->execution_mask is a single bit, rq->engine
>   	 * can be a physical engine with the exact corresponding mask.
>   	 */
> -	if (!intel_engine_is_virtual(rq->engine) &&
> -	    is_power_of_2(rq->execution_mask) &&
> +	if (is_power_of_2(rq->execution_mask) &&
> +	    !intel_engine_is_virtual(rq->engine) &&
>   	    !cmpxchg(&rq->engine->request_pool, NULL, rq))
>   		return;
>   

  reply	other threads:[~2023-06-05 16:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-05 16:48 [Intel-gfx] [PATCH] drm/i915: do not dereference dangling engine pointer on fence release Andrzej Hajda
2023-06-05 16:58 ` Nirmoy Das [this message]
2023-06-05 23:14 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2023-06-06 22:07 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

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=8f1a3827-5dee-628a-e278-d3fdd8e0a557@intel.com \
    --to=nirmoy.das@intel.com \
    --cc=andrzej.hajda@intel.com \
    --cc=chris.p.wilson@intel.com \
    --cc=intel-gfx@lists.freedesktop.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