Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit cc807fe4 authored by Pradeep P V K's avatar Pradeep P V K
Browse files

block: Fix race on request queue removal and cgroup controller



Avoid that the following race can occur:

blk_cleanup_queue()       blkcg_print_blkgs()
spin_lock_irq(lock) (1)   spin_lock_irq(blkg->q->queue_lock) (2,5)
q->queue_lock = &q->__queue_lock (3)
spin_unlock_irq(lock) (4)
                          spin_unlock_irq(blkg->q->queue_lock) (6)

(1) take driver lock;
(2) busy loop for driver lock;
(3) override driver lock with internal lock;
(4) unlock driver lock;
(5) can take driver lock now;
(6) but unlock internal lock.

This change is safe because only the SCSI core and the NVME core keep
a reference on a request queue after having called blk_cleanup_queue().
Neither driver accesses any of the removed data structures between its
blk_cleanup_queue() and blk_put_queue() calls.

Change-Id: I231cdcd45d3a880eeb744183860d943776ce2fee
Reported-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
Cc: Jan Kara <jack@suse.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Git-commit: a063057d7c731cffa7d10740e8ebc2970df8dbb3
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git


Signed-off-by: default avatarPradeep P V K <ppvk@codeaurora.org>
parent 83b2445d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment