Skip to content

Commit 0a95b85

Browse files
Qu Wenruomasoncl
authored andcommitted
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 <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent de0ee0e commit 0a95b85

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/async-thread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq,
328328
list_add_tail(&work->ordered_list, &wq->ordered_list);
329329
spin_unlock_irqrestore(&wq->list_lock, flags);
330330
}
331-
queue_work(wq->normal_wq, &work->normal_work);
332331
trace_btrfs_work_queued(work);
332+
queue_work(wq->normal_wq, &work->normal_work);
333333
}
334334

335335
void btrfs_queue_work(struct btrfs_workqueue *wq,

0 commit comments

Comments
 (0)