From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH 4/8] drm: Allow drm_mode_object_find() to look up an object of any type Date: Thu, 29 May 2014 14:17:27 +0200 Message-ID: <20140529121727.GC19050@phenom.ffwll.local> References: <1401321445-31906-1-git-send-email-robdclark@gmail.com> <1401321445-31906-5-git-send-email-robdclark@gmail.com> <20140529111820.GA19050@phenom.ffwll.local> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B1676E380 for ; Thu, 29 May 2014 05:17:35 -0700 (PDT) Received: by mail-we0-f181.google.com with SMTP id w61so291041wes.40 for ; Thu, 29 May 2014 05:17:35 -0700 (PDT) Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Rob Clark Cc: "dri-devel@lists.freedesktop.org" List-Id: dri-devel@lists.freedesktop.org On Thu, May 29, 2014 at 08:01:48AM -0400, Rob Clark wrote: > On Thu, May 29, 2014 at 7:18 AM, Daniel Vetter wrote: > > On Wed, May 28, 2014 at 07:57:21PM -0400, Rob Clark wrote: > >> From: Ville Syrj=E4l=E4 > >> > >> To avoid having to pass object types from userspace for atomic mode > >> setting ioctl, allow drm_mode_object_find() to look up an object of any > >> type. This will only work as long as the all object types share the ID > >> space. > >> > >> Signed-off-by: Ville Syrj=E4l=E4 > >> Signed-off-by: Rob Clark > > > > Still NACK. Iirc you only want a boolean "does this exist" so please ad= d a > > new function for this. Returning a full pointer for framebuffer is simp= ly > > unsafe, allowing that a call for trouble. Yes, I know your current code= is > > safe but I don't want to freak out and do an ad-hoc audit every time I > > stumble over this again. > = > this one isn't removing the (type !=3D FB_ID) check.. if you looked more > carefully at the other patches you'd realized I'd already changed this > ;-) Argh, today is an embarrassing day indeed. > I suppose for completeness we should add an obj->type !=3D FB_ID check > too, although it should *not* be a WARN_ON(). The one place it is > used is for atomic ioctl: > = > + obj =3D drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_ANY); > + if (!obj || !obj->properties) { > + ret =3D -ENOENT; > + goto out; > + } If you want to use this I think we need a new function drm_mode_object_has_properties or something, which checks whether the passed-in object_id is a framebuffer or not under the protection of the idr_mutex. Because the moment you drop that look obj can be freed if it's indeed an fb, and so all your obj->properties check walks into lalala-land. Or at least can. fb objects really have completely different lifetime rules so we need to be extremely careful with handling them ;-) -Daniel -- = Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch