cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
To: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Michel Lespinasse
	<walken-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Tahsin Erdogan <tahsin-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH for-linus 1/2] writeback, cgroup: fix premature wb_put() in locked_inode_to_wb_and_lock_list()
Date: Sun, 20 Mar 2016 09:44:44 -0600	[thread overview]
Message-ID: <56EEC56C.3030709@kernel.dk> (raw)
In-Reply-To: <20160318175003.GA20028-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>

On 03/18/2016 11:50 AM, Tejun Heo wrote:
> locked_inode_to_wb_and_lock_list() wb_get()'s the wb associated with
> the target inode, unlocks inode, locks the wb's list_lock and verifies
> that the inode is still associated with the wb.  To prevent the wb
> going away between dropping inode lock and acquiring list_lock, the wb
> is pinned while inode lock is held.  The wb reference is put right
> after acquiring list_lock citing that the wb won't be dereferenced
> anymore.
>
> This isn't true.  If the inode is still associated with the wb, the
> inode has reference and it's safe to return the wb; however, if inode
> has been switched, the wb still needs to be unlocked which is a
> dereference and can lead to use-after-free if it it races with wb
> destruction.
>
> Fix it by putting the reference after releasing list_lock.

Applied for current series, thanks Tejun.

-- 
Jens Axboe

      parent reply	other threads:[~2016-03-20 15:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02 22:26 [BUG] cgroup writeback list corruption Tahsin Erdogan
     [not found] ` <CAAeU0aMYeM_39Y2+PaRvyB1nqAPYZSNngJ1eBRmrxn7gKAt2Mg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-09 16:12   ` Tahsin Erdogan
     [not found]     ` <CAAeU0aPANgyD0dpQYwnuLioEymUzPgfU5JNG_QBz0fy_fn06ng-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-11 19:46       ` Tejun Heo
2016-03-16 22:10   ` Tejun Heo
     [not found]     ` <20160316221015.GL21104-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2016-03-17  1:13       ` Tejun Heo
     [not found]         ` <20160317011350.GN21104-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2016-03-17  2:36           ` Tahsin Erdogan
2016-03-18 17:50   ` [PATCH for-linus 1/2] writeback, cgroup: fix premature wb_put() in locked_inode_to_wb_and_lock_list() Tejun Heo
     [not found]     ` <20160318175003.GA20028-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2016-03-18 17:52       ` [PATCH for-linus 2/2] writeback, cgroup: fix use of the wrong bdi_writeback which mismatches the inode Tejun Heo
     [not found]         ` <20160318175204.GB20028-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2016-03-18 23:33           ` Tahsin Erdogan
2016-03-20 15:44       ` Jens Axboe [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=56EEC56C.3030709@kernel.dk \
    --to=axboe-tswwg44o7x1aa/9udqfwiw@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=jack-IBi9RG/b67k@public.gmane.org \
    --cc=tahsin-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=walken-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).