From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [RFC 04/44] drm/i915: Fix null pointer dereference in error capture Date: Mon, 7 Jul 2014 20:49:46 +0200 Message-ID: <20140707184946.GW5821@phenom.ffwll.local> References: <1403803475-16337-1-git-send-email-John.C.Harrison@Intel.com> <1403803475-16337-5-git-send-email-John.C.Harrison@Intel.com> <20140630144005.65c7c48d@jbarnes-desktop> <20140701071211.GC17834@nuc-i3427.alporthouse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-we0-f180.google.com (mail-we0-f180.google.com [74.125.82.180]) by gabe.freedesktop.org (Postfix) with ESMTP id 396A36E251 for ; Mon, 7 Jul 2014 11:49:36 -0700 (PDT) Received: by mail-we0-f180.google.com with SMTP id x48so4857018wes.25 for ; Mon, 07 Jul 2014 11:49:35 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20140701071211.GC17834@nuc-i3427.alporthouse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Chris Wilson , Jesse Barnes , John.C.Harrison@Intel.com, Intel-GFX@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Tue, Jul 01, 2014 at 08:12:11AM +0100, Chris Wilson wrote: > On Mon, Jun 30, 2014 at 02:40:05PM -0700, Jesse Barnes wrote: > > On Thu, 26 Jun 2014 18:23:55 +0100 > > John.C.Harrison@Intel.com wrote: > > > > > From: John Harrison > > > > > > The i915_gem_record_rings() code was unconditionally querying and saving state > > > for the batch_obj of a request structure. This is not necessarily set. Thus a > > > null pointer dereference can occur. > > > --- > > > drivers/gpu/drm/i915/i915_gpu_error.c | 13 +++++++------ > > > 1 file changed, 7 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c > > > index 87ec60e..0738f21 100644 > > > --- a/drivers/gpu/drm/i915/i915_gpu_error.c > > > +++ b/drivers/gpu/drm/i915/i915_gpu_error.c > > > @@ -902,12 +902,13 @@ static void i915_gem_record_rings(struct drm_device *dev, > > > * as the simplest method to avoid being overwritten > > > * by userspace. > > > */ > > > - error->ring[i].batchbuffer = > > > - i915_error_object_create(dev_priv, > > > - request->batch_obj, > > > - request->ctx ? > > > - request->ctx->vm : > > > - &dev_priv->gtt.base); > > > + if(request->batch_obj) > > > + error->ring[i].batchbuffer = > > > + i915_error_object_create(dev_priv, > > > + request->batch_obj, > > > + request->ctx ? > > > + request->ctx->vm : > > > + &dev_priv->gtt.base); > > > > > > if (HAS_BROKEN_CS_TLB(dev_priv->dev) && > > > ring->scratch.obj) > > > > Reviewed-by: Jesse Barnes > > Nah, put the NULL check into the macro. i915_error_object_create() was > originally written as a no-op on NULL pointers for cleanliness, we may > as well do the check centrally and remove the extras we have grown. Also the usual broken record from your maintainer: How does this blow up and can we please have a testcase for it? Oscar provided a basic error state check test, so the infrastructure for a new subtest is now there. I hope ;-) -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch