4.4-stable review patch. If anyone has any objections, please let me know.
------------------ From: Qu Wenruo <quwen...@cn.fujitsu.com> commit 0a95b851370b84a4b9d92ee6d1fa0926901d0454 upstream. Parameter of trace_btrfs_work_queued() can be freed in its workqueue. So no one use use that pointer after queue_work(). Fix the user-after-free bug by move the trace line before queue_work(). Reported-by: Dave Jones <da...@codemonkey.org.uk> Signed-off-by: Qu Wenruo <quwen...@cn.fujitsu.com> Reviewed-by: David Sterba <dste...@suse.com> Signed-off-by: Chris Mason <c...@fb.com> Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org> --- fs/btrfs/async-thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c @@ -328,8 +328,8 @@ static inline void __btrfs_queue_work(st 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); + queue_work(wq->normal_wq, &work->normal_work); } void btrfs_queue_work(struct btrfs_workqueue *wq,