mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Mason <clm@fb.com>
To: Dave Jones <davej@codemonkey.org.uk>,
	<linux-btrfs@vger.kernel.org>, <jbacik@fb.com>,
	<dsterba@suse.com>, Qu Wenruo <quwenruo@cn.fujitsu.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: use-after-free in perf_trace_btrfs__work
Date: Thu, 21 Jan 2016 12:06:15 -0500	[thread overview]
Message-ID: <20160121170615.ttsumvs6esf6t332@floor.thefacebook.com> (raw)
In-Reply-To: <20160115030731.GA24109@codemonkey.org.uk>

On Thu, Jan 14, 2016 at 10:07:31PM -0500, Dave Jones wrote:
> I just hit a bunch of instances of this spew..
> This is on Linus' tree from a few hours ago
> 
> ==================================================================
> BUG: KASAN: use-after-free in perf_trace_btrfs__work+0x1b1/0x2a0 [btrfs] at addr ffff8800b7ea2e60
> Read of size 8 by task trinity-c14/6745
> =============================================================================
> BUG kmalloc-256 (Not tainted): kasan: bad access detected
> -----------------------------------------------------------------------------
> 
> Disabling lock debugging due to kernel taint
> INFO: Allocated in btrfs_wq_submit_bio+0xd1/0x300 [btrfs] age=63 cpu=1 pid=6745
> 	___slab_alloc.constprop.70+0x4de/0x580
> 	__slab_alloc.isra.67.constprop.69+0x48/0x80
> 	kmem_cache_alloc_trace+0x24c/0x2e0
> 	btrfs_wq_submit_bio+0xd1/0x300 [btrfs]
> 	btrfs_submit_bio_hook+0x118/0x260 [btrfs]
> 	neigh_sysctl_register+0x201/0x360
> 	devinet_sysctl_register+0x73/0xe0
> 	inetdev_init+0x119/0x1f0
> 	inetdev_event+0x5b3/0x7e0
> 	notifier_call_chain+0x4e/0xd0
> 	raw_notifier_call_chain+0x16/0x20
> 	call_netdevice_notifiers_info+0x3d/0x70
> 	register_netdevice+0x62d/0x730
> 	register_netdev+0x1a/0x30
> 	loopback_net_init+0x5d/0xd0
> 	ops_init+0x5b/0x1e0
> INFO: Freed in run_one_async_free+0x12/0x20 [btrfs] age=177 cpu=1 pid=8018
> 	__slab_free+0x19e/0x2d0
> 	kfree+0x24e/0x270
> 	run_one_async_free+0x12/0x20 [btrfs]
> 	btrfs_scrubparity_helper+0x38d/0x740 [btrfs]
> 	btrfs_worker_helper+0xe/0x10 [btrfs]
> 	process_one_work+0x417/0xa40
> 	worker_thread+0x8b/0x730
> 	kthread+0x199/0x1c0
> 	ret_from_fork+0x3f/0x70
> INFO: Slab 0xffffea0002dfa800 objects=28 used=28 fp=0x          (null) flags=0x4000000000004080
> INFO: Object 0xffff8800b7ea2da0 @offset=11680 fp=0xffff8800b7ea2480

static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq,
                                      struct btrfs_work *work)
{
        unsigned long flags;
	
        work->wq = wq;
        thresh_queue_hook(wq);
        if (work->ordered_func) {
                spin_lock_irqsave(&wq->list_lock, flags);
                list_add_tail(&work->ordered_list, &wq->ordered_list);
                spin_unlock_irqrestore(&wq->list_lock, flags);
        }
        queue_work(wq->normal_wq, &work->normal_work);
        trace_btrfs_work_queued(work);
}

Qu, 'work' can be freed before queue_work returns.  I don't see any reason
here to have it after the queue_work() call, do you?

-chris

  reply	other threads:[~2016-01-21 17:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-15  3:07 Dave Jones
2016-01-21 17:06 ` Chris Mason [this message]
2016-01-22  0:31   ` Qu Wenruo

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=20160121170615.ttsumvs6esf6t332@floor.thefacebook.com \
    --to=clm@fb.com \
    --cc=davej@codemonkey.org.uk \
    --cc=dsterba@suse.com \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quwenruo@cn.fujitsu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®