From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: Re: [PATCH] drm: check for garbage in unused addfb2 fields Date: Tue, 26 May 2015 14:38:44 +0200 Message-ID: <20150526123842.GA21049@ulmo.nvidia.com> References: <1432133633-19965-1-git-send-email-daniel.vetter@ffwll.ch> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1432696117==" Return-path: In-Reply-To: <1432133633-19965-1-git-send-email-daniel.vetter@ffwll.ch> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Daniel Vetter Cc: Daniel Vetter , Intel Graphics Development , DRI Development List-Id: intel-gfx@lists.freedesktop.org --===============1432696117== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ReaqsoxgOBHFXBhH" Content-Disposition: inline --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 20, 2015 at 04:53:53PM +0200, Daniel Vetter wrote: > Unfortunately old userspace didn't clear this properly, but since > we've added fb modifiers that's fixed. Checking properly that unused > fields is important for abi extensions, and just right now there's a > bunch of discussions going on about how exactly the additional aux > planes for render compression should be specified. >=20 > So let's first make sure that the values in those additional fields > can be indeed used. >=20 > Cc: Thierry Reding > Testcase: igt/kms_addfb/unused-* > Signed-off-by: Daniel Vetter > --- > drivers/gpu/drm/drm_crtc.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) I think this is fine for now. There's still some unclarity about how exactly to pass in auxiliary planes, but in order to do so we need to prevent userspace from passing in garbage, so: Reviewed-by: Thierry Reding > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c > index 2e26988a9762..8ad582f4026b 100644 > --- a/drivers/gpu/drm/drm_crtc.c > +++ b/drivers/gpu/drm/drm_crtc.c > @@ -3308,6 +3308,32 @@ static int framebuffer_check(const struct drm_mode= _fb_cmd2 *r) > } > } > =20 > + for (i =3D num_planes; i < 4; i++) { > + if (r->modifier[i]) { > + DRM_DEBUG_KMS("non-zero modifier for unused plane %d\n", i); > + return -EINVAL; > + } > + > + /* Pre-FB_MODIFIERS userspace didn't clear the structs properly. */ > + if (!(r->flags & DRM_MODE_FB_MODIFIERS)) > + continue; > + > + if (r->handles[i]) { > + DRM_DEBUG_KMS("buffer object handle for unused plane %d\n", i); > + return -EINVAL; > + } > + > + if (r->pitches[i]) { > + DRM_DEBUG_KMS("non-zero pitch for unused plane %d\n", i); > + return -EINVAL; > + } > + > + if (r->offsets[i]) { > + DRM_DEBUG_KMS("non-zero offset for unused plane %d\n", i); > + return -EINVAL; > + } > + } > + > return 0; > } > =20 > --=20 > 2.1.4 >=20 --ReaqsoxgOBHFXBhH Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJVZGlPAAoJEN0jrNd/PrOh29gP/AvUaK+Y5hWjfxLS+p8jQSpf E0uZN3jdkiQtWub3zQLRY7TiyIdVuyYaA+lHBPvTb9n3uYGmarpcMaWgoUUMDKXW Klj5Nn6JCcmOxgk4DZLVJEzU9euCDDdxeFT8GG445qHARk8gs1UC7BOdmlNWoKid zfvs/uh4bi/+dE5ZKfzlXDHa2JlIf9lF7DkVEKu9EL4lUSL9JmbDUHd9rQa2ZL5b 6o2gMRpoXn0v7O+hBOevAXc3zJfgpqafL4Vzrj1ghNegDqQi1dkphwcbJhcO66YH bd8INK/OszwhuZRhJUSDekbY56yDV/aTe/IOqoAgf52T3taHxZhbrDR/A2M8jonl afzfDqGCDQ/GXAp0w0BeSv6Rp+/+rI9HJ/IU2eyM4T/OaCGtiC6IbIOj/+x66S2y yyVahikyd0rCmCyW2by/B2SOrXoMZMma/yMQnP4t4lnVbhGoruSFj4vwSEOranuF 9w6cBJbdmjg1XsVv+gjIH3VPCp3g+Xrfkih0/mDCy3oSHL5ZzU92sFL4wiRtKl6N 57Ha8OdAXNdGuzqmECEyDDObWARTihCC+tgsHMYe355+tBLHDgNQz7SuzUb88SyV 4QB+dZiHF0J+hrhn0IamawG4YW/+9wYBliJL0S9k+tUuDni2hawAvjAbMkJ6HAqC kO1tCNGJw0VoyDyUNCNO =bDcB -----END PGP SIGNATURE----- --ReaqsoxgOBHFXBhH-- --===============1432696117== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9kcmktZGV2ZWwK --===============1432696117==--