From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Barnes Subject: Re: [PATCH 5/7] drm: plane: Check crtc coodrinates against integer overflows in setplane ioctl Date: Fri, 11 Nov 2011 09:21:00 -0800 Message-ID: <20111111092100.3b0838fa@jbarnes-desktop> 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> <20111111171139.GD3477@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0321319946==" Return-path: Received: from oproxy7-pub.bluehost.com (oproxy7-pub.bluehost.com [67.222.55.9]) by gabe.freedesktop.org (Postfix) with SMTP id 0570C9E837 for ; Fri, 11 Nov 2011 09:20:39 -0800 (PST) In-Reply-To: <20111111171139.GD3477@intel.com> 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: Ville =?ISO-8859-1?B?U3lyauRs5A==?= Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============0321319946== Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/3fmBV7OK67IOQDOYgt3_tZ2"; protocol="application/pgp-signature" --Sig_/3fmBV7OK67IOQDOYgt3_tZ2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Fri, 11 Nov 2011 19:11:39 +0200 Ville Syrj=E4l=E4 wrote: > 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: > >=20 > > > From: Ville Syrj=E4l=E4 > > >=20 > > > Help drivers a little by guaranteeing that crtc_x+crtc_w and > > > crtc_y+crtc_h don't overflow. > > >=20 > > > Signed-off-by: Ville Syrj=E4l=E4 > > > --- > > > drivers/gpu/drm/drm_crtc.c | 12 ++++++++++++ > > > 1 files changed, 12 insertions(+), 0 deletions(-) > > >=20 > > > 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, = void *data, > > > goto out; > > > } > > > =20 > > > + /* 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, > >=20 > > Not sure this helps much in practice, since the drivers will have to > > validate the target CRTC rect against the actual pipe dimensions anyway. >=20 > 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. Ok that makes sense. The new patchset looks really nice; having helpers to support new chipsets and for regions should make things a lot cleaner. --=20 Jesse Barnes, Intel Open Source Technology Center --Sig_/3fmBV7OK67IOQDOYgt3_tZ2 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJOvVl8AAoJEIEoDkX4Qk9hHuQQAJkWGfn/hSY5dVAF4Z1a3O0I QN/RS+aEF2yW7mjM6mUVLQr3KDccEYx7hVfZuWYXlEobDlx9d9D8L81ycuwzafJx YT2a8efa07AjfUNz+VKpGh5dSROpyKRQ7MPHGvGtQkwqyKtJ/qFQfX3umiLRKZLB fUfHl9EtJ2CWzt3Gx/EkgG1U6Q48f2hKQuhmBAcz4mZfNogd6mgYUEHyk4vglF62 DKIuCLPVIy9fnHTkNFFpJ3aHWpuJOKggciOUkEVnOMmi5J4+eQBtYpr0yoRpMsCk 8Lq7h6Ll8AQEm97F4mIGjWrh4RL1fWGLEnc6903LNXuqjQSNbxrjm9VtyzNVoQEu Xwbtg5Ks1BdNcWSrrxjy4/5rcrsz7M91OEv9ogk8Dr89SXeJLgHb30LzKE+EStl1 NJNwTiC9rYXiILXk0pi50hiO9/wawNsrVH7PB6q71S1IjXuEhuP/o3PlNa+xi9GF NH+VjRTBQnnF5F+N5zsXBep3O0sk9JWrIqI/4IL4VxDN/uCXGGg7l9crgjpPPP9j Qfvj01H9wVvN5YthtBgtoxwGZC7mlA4cXeMoVqe+tk34ZXikef4eZkSME2BPeEA7 VAmgJ3wrlxREwUgDTeoCSdYRgkMyyoOkeVoEJJjnlurkM5+12itxcZBiYvkdRv4S YA1wggyzsGqVTOUyG/OL =0nlE -----END PGP SIGNATURE----- --Sig_/3fmBV7OK67IOQDOYgt3_tZ2-- --===============0321319946== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============0321319946==--