Skip to content

Commit

Permalink
block: fix use-after-free bug in blk throttle code
Browse files Browse the repository at this point in the history
blk_throtl_exit() frees the throttle data hanging off the queue
in blk_cleanup_queue(), but blk_put_queue() will indirectly
dereference this data when calling blk_sync_queue() which in
turns calls throtl_shutdown_timer_wq().

Fix this by moving the freeing of the throttle data to when
the queue is truly being released, and post the call to
blk_sync_queue().

Reported-by: Ingo Molnar <[email protected]>
Tested-by: Ingo Molnar <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Jens Axboe committed Oct 23, 2010
1 parent 7f38839 commit 7ad58c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 0 additions & 2 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,6 @@ void blk_cleanup_queue(struct request_queue *q)
if (q->elevator)
elevator_exit(q->elevator);

blk_throtl_exit(q);

blk_put_queue(q);
}
EXPORT_SYMBOL(blk_cleanup_queue);
Expand Down
2 changes: 2 additions & 0 deletions block/blk-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ static void blk_release_queue(struct kobject *kobj)

blk_sync_queue(q);

blk_throtl_exit(q);

if (rl->rq_pool)
mempool_destroy(rl->rq_pool);

Expand Down

0 comments on commit 7ad58c0

Please sign in to comment.