Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: protect debugfs attribute method hctx_busy_show

The hctx_busy_show method in debugfs is currently unprotected. This
method iterates over all started requests in a tagset and prints them.
However, the tags can be updated concurrently via the sysfs attributes
'nr_requests' or 'scheduler' (elevator switch), leading to potential
race conditions.

Since sysfs attributes 'nr_requests' and 'scheduler' are already
protected using q->elevator_lock, extend this protection to the debugfs
'busy' attribute as well to ensure consistency.

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20250313115235.3707600-4-nilay@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Nilay Shroff and committed by
Jens Axboe
0e94ed33 78800f59

+5
+5
block/blk-mq-debugfs.c
··· 347 347 { 348 348 struct blk_mq_hw_ctx *hctx = data; 349 349 struct show_busy_params params = { .m = m, .hctx = hctx }; 350 + int res; 350 351 352 + res = mutex_lock_interruptible(&hctx->queue->elevator_lock); 353 + if (res) 354 + return res; 351 355 blk_mq_tagset_busy_iter(hctx->queue->tag_set, hctx_show_busy_rq, 352 356 &params); 357 + mutex_unlock(&hctx->queue->elevator_lock); 353 358 354 359 return 0; 355 360 }