From: Chris Wilson Subject: Re: [PATCH 1/3] drm/i915: fix reference counting in i915_gem_create Date: Wed, 24 Jul 2013 13:26:01 +0100 Message-ID: <20130724122601.GH3299@cantiga.alporthouse.com> References: <1374663659-3073-1-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 fireflyinternet.com (s16502780.onlinehome-server.info [87.106.93.118]) by gabe.freedesktop.org (Postfix) with ESMTP id 805ADE69F9 for ; Wed, 24 Jul 2013 05:26:08 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1374663659-3073-1-git-send-email-daniel.vetter@ffwll.ch> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Daniel Vetter Cc: Intel Graphics Development List-Id: intel-gfx@lists.freedesktop.org On Wed, Jul 24, 2013 at 01:00:57PM +0200, Daniel Vetter wrote: > This function is called without the dev->struct_mutex held, hence we > need to use the _unlocked unreference variants. > > As soon as the object is registered userspace can sneak in here with a > gem_close ioctl call, so the object can (and with my new evil tests > actually does) get the final unreference in this place. The lack of > locking then results in hilarity and some good leakage. So there is a small race for a second thread on the fd to guess the new handle before the owner sees its. We should be able to push the transfer of ownership into the handle_create() routine to close this race with incurring any extra cost. -Chris -- Chris Wilson, Intel Open Source Technology Centre