From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jani Nikula Subject: Re: [Intel-gfx] [PATCH] drm/i915: Validate execbuffer start/length arguments against the target bo Date: Thu, 28 Apr 2016 11:51:51 +0300 Message-ID: <878tzyi09k.fsf@intel.com> References: <1448032264-31086-1-git-send-email-chris@chris-wilson.co.uk> <20151120153825.GS4437@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <20151120153825.GS4437@intel.com> Sender: stable-owner@vger.kernel.org To: Ville =?utf-8?B?U3lyasOkbMOk?= , Chris Wilson Cc: intel-gfx@lists.freedesktop.org, stable@vger.kernel.org List-Id: intel-gfx@lists.freedesktop.org On Fri, 20 Nov 2015, Ville Syrj=C3=A4l=C3=A4 wrote: > On Fri, Nov 20, 2015 at 03:11:04PM +0000, Chris Wilson wrote: >> The offset within and the length of the command sequence to execute = are >> supplied by the user with respect to the batch buffer. We should be >> validating that region is wholly contained within the batch buffer; >> make it so. >>=20 >> Reported-by: Ville Syrj=C3=A4l=C3=A4 >> Signed-off-by: Chris Wilson >> Cc: stable@vger.kernel.org >> --- >> drivers/gpu/drm/i915/i915_gem_execbuffer.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >>=20 >> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gp= u/drm/i915/i915_gem_execbuffer.c >> index a4c243cec4aa..e38284c1b89f 100644 >> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c >> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c >> @@ -1462,6 +1462,13 @@ i915_gem_do_execbuffer(struct drm_device *dev= , void *data, >> /* take note of the batch buffer before we might reorder the lists= */ >> batch_obj =3D eb_get_batch(eb); >> =20 >> + if (args->batch_len > batch_obj->base.size || >> + args->batch_start_offset > batch_obj->base.size - args->batch_= len) { > > lgtm. No possibility of overflow doing it that way. > > Reviewed-by: Ville Syrj=C3=A4l=C3=A4 > >> + DRM_DEBUG("Attempting to execute commands from beyond the bounds = of the batch object\n"); >> + ret =3D -EINVAL; >> + goto err; >> + } >> + >> /* Move the objects en-masse into the GTT, evicting if necessary. = */ >> need_relocs =3D (args->flags & I915_EXEC_NO_RELOC) =3D=3D 0; >> ret =3D i915_gem_execbuffer_reserve(ring, &eb->vmas, ctx, &need_re= locs); >> --=20 >> 2.6.2 >>=20 >> _______________________________________________ >> Intel-gfx mailing list >> Intel-gfx@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/intel-gfx --=20 Jani Nikula, Intel Open Source Technology Center