From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Subject: Re: [PATCH 5/7] drm: plane: Check crtc coodrinates against integer overflows in setplane ioctl Date: Fri, 11 Nov 2011 19:11:39 +0200 Message-ID: <20111111171139.GD3477@intel.com> References: <1321027447-17921-1-git-send-email-ville.syrjala@linux.intel.com> <1321027447-17921-6-git-send-email-ville.syrjala@linux.intel.com> <20111111090146.53157706@jbarnes-desktop> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 8509FA0ED8 for ; Fri, 11 Nov 2011 09:09:31 -0800 (PST) Content-Disposition: inline In-Reply-To: <20111111090146.53157706@jbarnes-desktop> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Jesse Barnes Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Fri, Nov 11, 2011 at 09:01:46AM -0800, Jesse Barnes wrote: > On Fri, 11 Nov 2011 18:04:05 +0200 > ville.syrjala@linux.intel.com wrote: > = > > From: Ville Syrj=E4l=E4 > > = > > Help drivers a little by guaranteeing that crtc_x+crtc_w and > > crtc_y+crtc_h don't overflow. > > = > > Signed-off-by: Ville Syrj=E4l=E4 > > --- > > drivers/gpu/drm/drm_crtc.c | 12 ++++++++++++ > > 1 files changed, 12 insertions(+), 0 deletions(-) > > = > > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c > > index 098cc50..2410a9a 100644 > > --- a/drivers/gpu/drm/drm_crtc.c > > +++ b/drivers/gpu/drm/drm_crtc.c > > @@ -1725,6 +1725,18 @@ int drm_mode_setplane(struct drm_device *dev, vo= id *data, > > goto out; > > } > > = > > + /* Give drivers some help against integer overflows */ > > + if (plane_req->crtc_w > INT_MAX || > > + plane_req->crtc_x > INT_MAX - (int32_t) plane_req->crtc_w || > > + plane_req->crtc_h > INT_MAX || > > + plane_req->crtc_y > INT_MAX - (int32_t) plane_req->crtc_h) { > > + DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n", > > + plane_req->crtc_w, plane_req->crtc_h, > > + plane_req->crtc_x, plane_req->crtc_y); > > + ret =3D -EINVAL; > > + goto out; > > + } > > + > > ret =3D plane->funcs->update_plane(plane, crtc, fb, > > plane_req->crtc_x, plane_req->crtc_y, > > plane_req->crtc_w, plane_req->crtc_h, > = > Not sure this helps much in practice, since the drivers will have to > validate the target CRTC rect against the actual pipe dimensions anyway. My master plan is that drivers would just stick these into a drm_region (introduced in my other patchset) and clip that to the pipe dimensions. -- = Ville Syrj=E4l=E4 Intel OTC