From: David Sterba <dsterba@suse.cz>
To: Liu Bo <bo.li.liu@oracle.com>
Cc: dsterba@suse.cz, linux-btrfs@vger.kernel.org, jbacik@fusionio.com
Subject: Re: [bug] 3.9-rc7+next: NULL deref in btrfs_next_old_leaf/btrfs_search_slot
Date: Tue, 30 Apr 2013 00:17:50 +0200 [thread overview]
Message-ID: <20130429221750.GT16427@twin.jikos.cz> (raw)
In-Reply-To: <20130427025042.GB999@liubo>
On Sat, Apr 27, 2013 at 10:50:43AM +0800, Liu Bo wrote:
> > @@ -3486,14 +3486,14 @@ int close_ctree(struct btrfs_root *root)
> > percpu_counter_sum(&fs_info->delalloc_bytes));
> > }
> >
> > - free_root_pointers(fs_info, 1);
> > -
> > btrfs_free_block_groups(fs_info);
> >
> > del_fs_roots(fs_info);
> >
> > iput(fs_info->btree_inode);
> >
> > + free_root_pointers(fs_info, 1);
> > +
> > btrfs_stop_workers(&fs_info->generic_worker);
> > btrfs_stop_workers(&fs_info->fixup_workers);
> > btrfs_stop_workers(&fs_info->delalloc_workers);
> > ---
>
> Thanks for tracking it Dave, I'm trying to reproduce it here.
Adding sleeps between free_root_pointers and stopping workers should
leave enough space for the threads to work and touch the freed data.
The proposed fix is not entirely correct, it just reduces the race
window. Freeing roots must come after stopping the workers, same holds
for any of the other cleanup functions that may access released
resources. But for example the free block groups need the caching thread
alive so it cannot be trivially fixed by moving everything after
stop_workers and must be decided case by case.
There is another instance of a similar sequence that is mis-ordered and
has to be fixed as well.
david
prev parent reply other threads:[~2013-04-29 22:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-18 14:42 [bug] 3.9-rc7+next: NULL deref in btrfs_next_old_leaf/btrfs_search_slot David Sterba
2013-04-18 14:49 ` David Sterba
2013-04-25 17:18 ` David Sterba
2013-04-27 2:50 ` Liu Bo
2013-04-29 22:17 ` David Sterba [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=20130429221750.GT16427@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=bo.li.liu@oracle.com \
--cc=jbacik@fusionio.com \
--cc=linux-btrfs@vger.kernel.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