Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Summers, Stuart" <stuart.summers@intel.com>
To: "tvrtko.ursulin@linux.intel.com" <tvrtko.ursulin@linux.intel.com>
Cc: "intel-gfx@lists.freedesktop.org" <intel-gfx@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH 2/2] drm/i915: Only disable PMU on stop if not already closed
Date: Thu, 4 Aug 2022 18:56:43 +0000	[thread overview]
Message-ID: <3fed807b5b6dc48ca1996b0df875e9a56d2e200f.camel@intel.com> (raw)
In-Reply-To: <e5e6bd39-de83-63bf-4798-8a58a5328720@linux.intel.com>

On Thu, 2022-08-04 at 09:46 +0100, Tvrtko Ursulin wrote:
> On 04/08/2022 00:03, Stuart Summers wrote:
> > There can be a race in the PMU process teardown vs the
> > time when the driver is unbound in which the user attempts
> > to stop the PMU process, but the actual data structure
> > in the kernel is no longer available. Avoid this use-after-free
> > by skipping the PMU disable in i915_pmu_event_stop() when
> > the PMU has already been closed/unregistered by the driver.
> > 
> > Fixes: b00bccb3f0bb ("drm/i915/pmu: Handle PCI unbind")
> > Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> > Signed-off-by: Stuart Summers <stuart.summers@intel.com>
> > ---
> >   drivers/gpu/drm/i915/i915_pmu.c | 8 ++++++++
> >   1 file changed, 8 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_pmu.c
> > b/drivers/gpu/drm/i915/i915_pmu.c
> > index 958b37123bf12..0d02f338118e4 100644
> > --- a/drivers/gpu/drm/i915/i915_pmu.c
> > +++ b/drivers/gpu/drm/i915/i915_pmu.c
> > @@ -760,9 +760,17 @@ static void i915_pmu_event_start(struct
> > perf_event *event, int flags)
> >   
> >   static void i915_pmu_event_stop(struct perf_event *event, int
> > flags)
> >   {
> > +	struct drm_i915_private *i915 =
> > +		container_of(event->pmu, typeof(*i915), pmu.base);
> > +	struct i915_pmu *pmu = &i915->pmu;
> > +
> > +	if (pmu->closed)
> > +		goto out;
> > +
> >   	if (flags & PERF_EF_UPDATE)
> >   		i915_pmu_event_read(event);
> >   	i915_pmu_disable(event);
> > +out:
> >   	event->hw.state = PERF_HES_STOPPED;
> >   }
> >   
> 
> LGTM, although I am not sure who feels comfortable to r-b since we
> all 
> kind of suggested the same fix. :)
> 
> FWIW:
> 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Thanks Tvrtko! I'll track down another reviewer here as well to close
that out before merging.

Thanks,
Stuart

> 
> Regards,
> 
> Tvrtko

  reply	other threads:[~2022-08-04 18:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 23:03 [Intel-gfx] [PATCH 1/2] drm/i915: Fix NPD in PMU during driver teardown Stuart Summers
2022-08-03 23:03 ` [Intel-gfx] [PATCH 2/2] drm/i915: Only disable PMU on stop if not already closed Stuart Summers
2022-08-04  8:46   ` Tvrtko Ursulin
2022-08-04 18:56     ` Summers, Stuart [this message]
2022-08-04 23:26   ` Umesh Nerlige Ramappa
2022-08-03 23:50 ` [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Fix NPD in PMU during driver teardown Patchwork
2022-08-04  6:29 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-08-04  8:42 ` [Intel-gfx] [PATCH 1/2] " Tvrtko Ursulin
2022-08-04 18:56   ` Summers, Stuart
2022-08-05  9:26     ` Tvrtko Ursulin

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=3fed807b5b6dc48ca1996b0df875e9a56d2e200f.camel@intel.com \
    --to=stuart.summers@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tvrtko.ursulin@linux.intel.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