From: Daniel Vetter <daniel@ffwll.ch>
To: Rob Clark <robdclark@gmail.com>
Cc: "dri-devel@lists.freedesktop.org" <dri-devel@lists.freedesktop.org>
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 [thread overview]
Message-ID: <20140529121727.GC19050@phenom.ffwll.local> (raw)
In-Reply-To: <CAF6AEGu-PvZWbYnme=Ajxba0S3uEg=x+koVbo2ikUN0hcun92w@mail.gmail.com>
On Thu, May 29, 2014 at 08:01:48AM -0400, Rob Clark wrote:
> On Thu, May 29, 2014 at 7:18 AM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > On Wed, May 28, 2014 at 07:57:21PM -0400, Rob Clark wrote:
> >> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>
> >> 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älä <ville.syrjala@linux.intel.com>
> >> Signed-off-by: Rob Clark <robdclark@gmail.com>
> >
> > Still NACK. Iirc you only want a boolean "does this exist" so please add a
> > new function for this. Returning a full pointer for framebuffer is simply
> > 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 != 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 != FB_ID check
> too, although it should *not* be a WARN_ON(). The one place it is
> used is for atomic ioctl:
>
> + obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_ANY);
> + if (!obj || !obj->properties) {
> + ret = -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
next prev parent reply other threads:[~2014-05-29 12:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-28 23:57 [PATCH 0/8] prepare for preparing for atomic Rob Clark
2014-05-28 23:57 ` [PATCH 1/8] drm: add object property type Rob Clark
2014-05-29 8:01 ` David Herrmann
2014-05-29 11:45 ` Rob Clark
2014-05-30 7:57 ` Thierry Reding
2014-05-30 12:00 ` Rob Clark
2014-05-28 23:57 ` [PATCH 2/8] drm: add signed-range " Rob Clark
2014-05-29 8:29 ` David Herrmann
2014-05-29 11:51 ` Rob Clark
2014-05-28 23:57 ` [PATCH 3/8] drm: helpers to find mode objects Rob Clark
2014-05-28 23:57 ` [PATCH 4/8] drm: Allow drm_mode_object_find() to look up an object of any type Rob Clark
2014-05-29 11:18 ` Daniel Vetter
2014-05-29 12:01 ` Rob Clark
2014-05-29 12:17 ` Daniel Vetter [this message]
2014-05-28 23:57 ` [PATCH 5/8] drm: spiff out FB refcnting traces Rob Clark
2014-05-29 8:36 ` David Herrmann
2014-05-28 23:57 ` [PATCH 6/8] drm: push locking down into restore_fbdev_mode (v2) Rob Clark
2014-05-28 23:57 ` [PATCH 7/8] drm: Split connection_mutex out of mode_config.mutex (v2) Rob Clark
2014-05-28 23:57 ` [PATCH 8/8] drm: convert crtc and connection_mutex to ww_mutex Rob Clark
2014-05-29 11:22 ` Daniel Vetter
2014-05-29 12:07 ` Rob Clark
2014-05-29 12:59 ` [PATCH 1/2] v2 (Daniel): - Readd lost include. - Drop all the additional complexity which we only need later: The basic ww dance only requires the lock list and the contended pointer, nothing more. Some of the stuff also looks very suspicious. - Improve the contended checks a bit to make sure we only get an -EALREADY when we expect it. - Add an interruptible backoff function just to be complete (since otherwise the interruptible locking function makes 0 sense at all). - Inline the slowpath (due to the above). - Move ww_acquire_fini into drm_modeset_acquire_fini. I suspect this has been due to the confusion about the lifetime of the acquire ctx wrt the locking retry loop. - Drop uapi changes, they really shouldn't be in this patch. - s/!ret/ret == 0/ because I got confused - I tend to use !ret only for booleans or pointers, not for errno integer return values Daniel Vetter
2014-05-29 12:59 ` [PATCH 2/2] Revert "v2 (Daniel):" Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140529121727.GC19050@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=robdclark@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox