From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH 36/39] drm: hollow-out GET_CLIENT ioctl Date: Tue, 16 Jul 2013 14:33:53 +0200 Message-ID: <20130716123353.GS5784@phenom.ffwll.local> References: <1373458333-5988-1-git-send-email-daniel.vetter@ffwll.ch> <1373458333-5988-37-git-send-email-daniel.vetter@ffwll.ch> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ea0-f182.google.com (mail-ea0-f182.google.com [209.85.215.182]) by gabe.freedesktop.org (Postfix) with ESMTP id 58FC9E6BC5 for ; Tue, 16 Jul 2013 05:33:53 -0700 (PDT) Received: by mail-ea0-f182.google.com with SMTP id d10so348488eaj.13 for ; Tue, 16 Jul 2013 05:33:52 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1373458333-5988-37-git-send-email-daniel.vetter@ffwll.ch> 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: DRI Development Cc: Daniel Vetter List-Id: dri-devel@lists.freedesktop.org On Wed, Jul 10, 2013 at 02:12:10PM +0200, Daniel Vetter wrote: > We not only have debugfs files to do pretty much the equivalent of > lsof, we also have an ioctl. Not that compared to lsof this dumps a > wee bit more information, but we can still get at that from debugfs > easily. > > I've dug around in mesa, libdrm and ddx histories and the only users > seem to be drm/tests/dristat.c and drm/tests/getclients.c. The later > is a testcase for the ioctl itself since up to > > commit b018fcdaa5e8b4eabb8cffda687d00004a3c4785 > Author: Eric Anholt > Date: Thu Nov 22 18:46:54 2007 +1000 > > drm: Make DRM_IOCTL_GET_CLIENT return EINVAL when it can't find client #idx > > there was actually no way at all for userspace to enumerate all > clients since the kernel just wouldn't tell it when to stop. Which > completely broke it's only user, dristat -c. > > So obviously that ioctl wasn't much use for debugging. Hence I don't > see any point in keeping support for a tool which was pretty obviously > never really used, and while we have good replacements in the form of > equivalent debugfs files. > > Still, to keep dristat -c from looping forever again stop it early by > returning an unconditional -EINVAL. Also add a comment in the code > about why. > > Cc: Eric Anholt > Signed-off-by: Daniel Vetter libva for the rescue (or not)! Thanks to a patch floating by on libva I've noticed that libva's dri loader used the GET_CLIENT ioctl to *drumroll* check whether it's authenticated. I can't even grasp that part, but in any case this patch here just died in it's current form :( I'll figure out whether there's some fun way to keep the hollowed-out ioclt without breaking existing userspace, but probably not worth the fuzz. -Daniel > --- > drivers/gpu/drm/drm_ioctl.c | 27 ++++----------------------- > 1 file changed, 4 insertions(+), 23 deletions(-) > > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c > index 0acf080..5159fa0 100644 > --- a/drivers/gpu/drm/drm_ioctl.c > +++ b/drivers/gpu/drm/drm_ioctl.c > @@ -216,29 +216,10 @@ int drm_getmap(struct drm_device *dev, void *data, > int drm_getclient(struct drm_device *dev, void *data, > struct drm_file *file_priv) > { > - struct drm_client *client = data; > - struct drm_file *pt; > - int idx; > - int i; > - > - idx = client->idx; > - i = 0; > - > - mutex_lock(&dev->struct_mutex); > - list_for_each_entry(pt, &dev->filelist, lhead) { > - if (i++ >= idx) { > - client->auth = pt->authenticated; > - client->pid = pid_vnr(pt->pid); > - client->uid = from_kuid_munged(current_user_ns(), pt->uid); > - client->magic = pt->magic; > - client->iocs = pt->ioctl_count; > - mutex_unlock(&dev->struct_mutex); > - > - return 0; > - } > - } > - mutex_unlock(&dev->struct_mutex); > - > + /* Hollowed-out getclient ioctl to keep some dead old drm tests/tools > + * not breaking completely. Userspace tools stop enumerating one they > + * get -EINVAL, hence this is the return value we need to hand back for > + * no clients tracked. */ > return -EINVAL; > } > > -- > 1.8.3.2 > -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch