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.

ublk: check for unprivileged daemon on each I/O fetch

Commit ab03a61c6614 ("ublk: have a per-io daemon instead of a per-queue
daemon") allowed each ublk I/O to have an independent daemon task.
However, nr_privileged_daemon is only computed based on whether the last
I/O fetched in each ublk queue has an unprivileged daemon task.
Fix this by checking whether every fetched I/O's daemon is privileged.
Change nr_privileged_daemon from a count of queues to a boolean
indicating whether any I/Os have an unprivileged daemon.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Fixes: ab03a61c6614 ("ublk: have a per-io daemon instead of a per-queue daemon")
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250808155216.296170-1-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Caleb Sander Mateos and committed by
Jens Axboe
5058a628 212c928d

+7 -9
+7 -9
drivers/block/ublk_drv.c
··· 235 235 236 236 struct completion completion; 237 237 unsigned int nr_queues_ready; 238 - unsigned int nr_privileged_daemon; 238 + bool unprivileged_daemons; 239 239 struct mutex cancel_mutex; 240 240 bool canceling; 241 241 pid_t ublksrv_tgid; ··· 1551 1551 /* set to NULL, otherwise new tasks cannot mmap io_cmd_buf */ 1552 1552 ub->mm = NULL; 1553 1553 ub->nr_queues_ready = 0; 1554 - ub->nr_privileged_daemon = 0; 1554 + ub->unprivileged_daemons = false; 1555 1555 ub->ublksrv_tgid = -1; 1556 1556 } 1557 1557 ··· 1978 1978 __must_hold(&ub->mutex) 1979 1979 { 1980 1980 ubq->nr_io_ready++; 1981 - if (ublk_queue_ready(ubq)) { 1981 + if (ublk_queue_ready(ubq)) 1982 1982 ub->nr_queues_ready++; 1983 - 1984 - if (capable(CAP_SYS_ADMIN)) 1985 - ub->nr_privileged_daemon++; 1986 - } 1983 + if (!ub->unprivileged_daemons && !capable(CAP_SYS_ADMIN)) 1984 + ub->unprivileged_daemons = true; 1987 1985 1988 1986 if (ub->nr_queues_ready == ub->dev_info.nr_hw_queues) { 1989 1987 /* now we are ready for handling ublk io request */ ··· 2876 2878 2877 2879 ublk_apply_params(ub); 2878 2880 2879 - /* don't probe partitions if any one ubq daemon is un-trusted */ 2880 - if (ub->nr_privileged_daemon != ub->nr_queues_ready) 2881 + /* don't probe partitions if any daemon task is un-trusted */ 2882 + if (ub->unprivileged_daemons) 2881 2883 set_bit(GD_SUPPRESS_PART_SCAN, &disk->state); 2882 2884 2883 2885 ublk_get_device(ub);