From: Tejun Heo <tj@kernel.org>
To: Xiaotian Feng <xtfeng@gmail.com>
Cc: Vivek Goyal <vgoyal@redhat.com>,
axboe@kernel.dk, linux-kernel@vger.kernel.org,
Xiaotian Feng <dannyfeng@tencent.com>
Subject: Re: [PATCH v2] block: fix ioc leak in put_io_context
Date: Tue, 13 Mar 2012 15:47:49 -0700 [thread overview]
Message-ID: <20120313224749.GH7349@google.com> (raw)
In-Reply-To: <CAJn8CcHk3Q1ke7839s+pKzkEeo6dGdNsZBHhEUek7c7=dp3y3w@mail.gmail.com>
On Wed, Mar 14, 2012 at 06:44:22AM +0800, Xiaotian Feng wrote:
> On Tue, Mar 13, 2012 at 11:49 PM, Tejun Heo <tj@kernel.org> wrote:
> > On Tue, Mar 13, 2012 at 10:28:20AM -0400, Vivek Goyal wrote:
> >> On Tue, Mar 13, 2012 at 01:21:06PM -0400, Xiaotian Feng wrote:
> >> > diff --git a/block/blk-ioc.c b/block/blk-ioc.c
> >> > index 8b782a6..9690f27 100644
> >> > --- a/block/blk-ioc.c
> >> > +++ b/block/blk-ioc.c
> >> > @@ -145,6 +145,7 @@ static void ioc_release_fn(struct work_struct *work)
> >> > void put_io_context(struct io_context *ioc)
> >> > {
> >> > unsigned long flags;
> >> > + bool free_ioc = false;
> >> >
> >> > if (ioc == NULL)
> >> > return;
> >> > @@ -159,8 +160,13 @@ void put_io_context(struct io_context *ioc)
> >> > spin_lock_irqsave(&ioc->lock, flags);
> >> > if (!hlist_empty(&ioc->icq_list))
> >> > schedule_work(&ioc->release_work);
> >> > + else
> >> > + free_ioc = true;
> >
> > Calling kmem_cache_free() here directly is probably better.
>
> I did this on my first try, but I got a kernel warning with the
> following spin_unlock on ioc->lock :(
> We'll hit a use after free bug then...
Ah, you're right. Thanks.
--
tejun
prev parent reply other threads:[~2012-03-13 22:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-12 14:59 [PATCH] block: fix ioc leak in put_io_context Xiaotian Feng
2012-03-12 14:22 ` Vivek Goyal
2012-03-13 17:21 ` [PATCH v2] " Xiaotian Feng
2012-03-13 14:28 ` Vivek Goyal
2012-03-13 14:40 ` Jens Axboe
2012-03-13 15:49 ` Tejun Heo
2012-03-13 22:44 ` Xiaotian Feng
2012-03-13 22:47 ` Tejun Heo [this message]
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=20120313224749.GH7349@google.com \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=dannyfeng@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vgoyal@redhat.com \
--cc=xtfeng@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.