From: Chris Wilson <chris@chris-wilson.co.uk>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: ben@bwidawsk.net, daniel.vetter@ffwll.ch, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/i915: Fix refcount leak and possible NULL pointerdereference.
Date: Fri, 3 Jan 2014 12:51:51 +0000 [thread overview]
Message-ID: <20140103125151.GA4367@nuc-i3427.alporthouse.com> (raw)
In-Reply-To: <201401032042.BJF09317.FJFQOFOVtSOLMH@I-love.SAKURA.ne.jp>
On Fri, Jan 03, 2014 at 08:42:18PM +0900, Tetsuo Handa wrote:
> Chris Wilson wrote:
> > On Tue, Dec 24, 2013 at 08:50:23PM +0900, Tetsuo Handa wrote:
> > > >From 482be6384379072eb4c0d45d0ab8a25df4f59ed7 Mon Sep 17 00:00:00 2001
> > > From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> > > Date: Tue, 24 Dec 2013 18:04:14 +0900
> > > Subject: [PATCH] drm/i915: Fix refcount leak and possible NULL pointer dereference.
> > >
> > > Since get_pid_task() grabs a reference on the task_struct, we have to drop the
> > > refcount after reading that task's comm name. Also, directly reading like
> > > get_pid_task()->comm can trigger an oops when get_pid_task() returned NULL.
> >
> > The second issue is moot as file itself cannot exist if the task_struct
> > is NULL, and the task_struct cannot be destroyed until we finish the
> > function. The simpler fix would appear to be s/get_pid_task/pid_task/
>
> If I understand correctly, priv->pid = get_pid(task_pid(current)); in
> drm_open_helper() grabs a reference on "struct pid" before adding to
> &dev->filelist, and put_pid(file_priv->pid); in drm_release() releases that
> reference after removing from &dev->filelist.
>
> So, you meant that mutex_lock_interruptible(&dev->struct_mutex); in
> i915_gem_object_info() prevents drm_release() from calling put_pid() ?
Right, my understanding is that since we take the struct_mutex during
release of the filp (and across this list walker) that is sufficient
serialisation to prevent the task struct from disappearing from
underneath us.
> Then, this file->pid in &dev->filelist keeps at least one reference.
> OK. Updated patch follows.
Looks good to me, and the comment is great.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
next prev parent reply other threads:[~2014-01-03 12:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-24 11:50 [PATCH] drm/i915: Fix refcount leak and possible NULL pointer dereference Tetsuo Handa
2013-12-25 21:52 ` Chris Wilson
2013-12-26 0:45 ` Tetsuo Handa
2014-01-03 11:42 ` [PATCH] drm/i915: Fix refcount leak and possible NULL pointerdereference Tetsuo Handa
2014-01-03 12:51 ` Chris Wilson [this message]
2014-01-05 1:08 ` [PATCH] drm/i915: Fix refcount leak and possible NULL pointer dereference Tetsuo Handa
2014-01-06 9:57 ` 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=20140103125151.GA4367@nuc-i3427.alporthouse.com \
--to=chris@chris-wilson.co.uk \
--cc=ben@bwidawsk.net \
--cc=daniel.vetter@ffwll.ch \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
/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