Skip to content

Commit

Permalink
blk-mq: Do not invoke queue operations on a dead queue
Browse files Browse the repository at this point in the history
In commit e869b54 ("blk-mq: Unregister debugfs attributes
earlier"), we shuffled the debugfs cleanup around so that the "state"
attribute was removed before we freed the blk-mq data structures.
However, later changes are going to undo that, so we need to explicitly
disallow running a dead queue.

[Omar: rebased and updated commit message]
Signed-off-by: Omar Sandoval <[email protected]>
Signed-off-by: Bart Van Assche <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Bart Van Assche authored and axboe committed May 4, 2017
1 parent f57de23 commit 18d4d7d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions block/blk-mq-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ static ssize_t queue_state_write(void *data, const char __user *buf,
struct request_queue *q = data;
char opbuf[16] = { }, *op;

/*
* The "state" attribute is removed after blk_cleanup_queue() has called
* blk_mq_free_queue(). Return if QUEUE_FLAG_DEAD has been set to avoid
* triggering a use-after-free.
*/
if (blk_queue_dead(q))
return -ENOENT;

if (count >= sizeof(opbuf)) {
pr_err("%s: operation too long\n", __func__);
goto inval;
Expand Down

0 comments on commit 18d4d7d

Please sign in to comment.