Skip to content

Commit 5274b16

Browse files
author
Ming Lei
committed
block: protect debugfs attribute method hctx_busy_show
JIRA: https://issues.redhat.com/browse/RHEL-112997 commit 0e94ed3 Author: Nilay Shroff <[email protected]> Date: Thu Mar 13 17:21:52 2025 +0530 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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Ming Lei <[email protected]>
1 parent b80b2d1 commit 5274b16

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

block/blk-mq-debugfs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,14 @@ static int hctx_busy_show(void *data, struct seq_file *m)
347347
{
348348
struct blk_mq_hw_ctx *hctx = data;
349349
struct show_busy_params params = { .m = m, .hctx = hctx };
350+
int res;
350351

352+
res = mutex_lock_interruptible(&hctx->queue->elevator_lock);
353+
if (res)
354+
return res;
351355
blk_mq_tagset_busy_iter(hctx->queue->tag_set, hctx_show_busy_rq,
352356
&params);
357+
mutex_unlock(&hctx->queue->elevator_lock);
353358

354359
return 0;
355360
}

0 commit comments

Comments
 (0)