Browse Source

btrfs: async-thread: Fix a use-after-free error for trace

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 <davej@codemonkey.org.uk>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Qu Wenruo 9 years ago
parent
commit
0a95b85137
1 changed files with 1 additions and 1 deletions
  1. 1 1
      fs/btrfs/async-thread.c

+ 1 - 1
fs/btrfs/async-thread.c

@@ -328,8 +328,8 @@ static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq,
 		list_add_tail(&work->ordered_list, &wq->ordered_list);
 		list_add_tail(&work->ordered_list, &wq->ordered_list);
 		spin_unlock_irqrestore(&wq->list_lock, flags);
 		spin_unlock_irqrestore(&wq->list_lock, flags);
 	}
 	}
-	queue_work(wq->normal_wq, &work->normal_work);
 	trace_btrfs_work_queued(work);
 	trace_btrfs_work_queued(work);
+	queue_work(wq->normal_wq, &work->normal_work);
 }
 }
 
 
 void btrfs_queue_work(struct btrfs_workqueue *wq,
 void btrfs_queue_work(struct btrfs_workqueue *wq,