Re: [Intel-gfx] [PATCH] drm/i915/ppgtt: Prevent NULL deref in reset ioctl

2013-12-20 Thread Ben Widawsky
On Fri, Dec 20, 2013 at 04:37:34PM +0200, Jani Nikula wrote: > On Fri, 20 Dec 2013, Daniel Vetter wrote: > > On Thu, Dec 19, 2013 at 10:55:56PM -0800, Ben Widawsky wrote: > >> On Fri, Dec 20, 2013 at 07:05:10AM +0100, Daniel Vetter wrote: > >> > On Fri, Dec 20, 2013 at 12:22 AM, Ben Widawsky > >>

Re: [Intel-gfx] [PATCH] drm/i915/ppgtt: Prevent NULL deref in reset ioctl

2013-12-20 Thread Ben Widawsky
On Fri, Dec 20, 2013 at 03:11:09PM +0100, Daniel Vetter wrote: > On Thu, Dec 19, 2013 at 10:55:56PM -0800, Ben Widawsky wrote: > > On Fri, Dec 20, 2013 at 07:05:10AM +0100, Daniel Vetter wrote: > > > On Fri, Dec 20, 2013 at 12:22 AM, Ben Widawsky > > > wrote: > > > > ctx = i915_gem_context

Re: [Intel-gfx] [PATCH] drm/i915/ppgtt: Prevent NULL deref in reset ioctl

2013-12-20 Thread Jani Nikula
On Fri, 20 Dec 2013, Daniel Vetter wrote: > On Thu, Dec 19, 2013 at 10:55:56PM -0800, Ben Widawsky wrote: >> On Fri, Dec 20, 2013 at 07:05:10AM +0100, Daniel Vetter wrote: >> > On Fri, Dec 20, 2013 at 12:22 AM, Ben Widawsky >> > wrote: >> > > ctx = i915_gem_context_get(file->driver_priv,

Re: [Intel-gfx] [PATCH] drm/i915/ppgtt: Prevent NULL deref in reset ioctl

2013-12-20 Thread Daniel Vetter
On Thu, Dec 19, 2013 at 10:55:56PM -0800, Ben Widawsky wrote: > On Fri, Dec 20, 2013 at 07:05:10AM +0100, Daniel Vetter wrote: > > On Fri, Dec 20, 2013 at 12:22 AM, Ben Widawsky > > wrote: > > > ctx = i915_gem_context_get(file->driver_priv, args->ctx_id); > > > - if (IS_ERR(ctx)) { >

Re: [Intel-gfx] [PATCH] drm/i915/ppgtt: Prevent NULL deref in reset ioctl

2013-12-19 Thread Ben Widawsky
On Fri, Dec 20, 2013 at 07:05:10AM +0100, Daniel Vetter wrote: > On Fri, Dec 20, 2013 at 12:22 AM, Ben Widawsky > wrote: > > ctx = i915_gem_context_get(file->driver_priv, args->ctx_id); > > - if (IS_ERR(ctx)) { > > + if (IS_ERR_OR_NULL(ctx)) { > > We now have half the callers

Re: [Intel-gfx] [PATCH] drm/i915/ppgtt: Prevent NULL deref in reset ioctl

2013-12-19 Thread Daniel Vetter
On Fri, Dec 20, 2013 at 12:22 AM, Ben Widawsky wrote: > ctx = i915_gem_context_get(file->driver_priv, args->ctx_id); > - if (IS_ERR(ctx)) { > + if (IS_ERR_OR_NULL(ctx)) { We now have half the callers check for IS_ERR and the others not. Afaics i915_gem_context_get can only ret

[Intel-gfx] [PATCH] drm/i915/ppgtt: Prevent NULL deref in reset ioctl

2013-12-19 Thread Ben Widawsky
If we look up an invalid context ID, the idr will return NULL. The ptr is unconditionally dereferenced afterwards causing a problem. Note that if the context does not exist, we still return success. This appears to be the behavior desired by gem_reset_stats --subtest ban Introduced in v3 of commi