Skip to content

Commit

Permalink
ublk: fail to start device if queue setup is interrupted
Browse files Browse the repository at this point in the history
[ Upstream commit 53e7d08 ]

In ublk_ctrl_start_dev(), if wait_for_completion_interruptible() is
interrupted by signal, queues aren't setup successfully yet, so we
have to fail UBLK_CMD_START_DEV, otherwise kernel oops can be triggered.

Reported by German when working on qemu-storage-deamon which requires
single thread ublk daemon.

Fixes: 71f28f3 ("ublk_drv: add io_uring based userspace block driver")
Reported-by: German Maglione <gmaglione@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230726144502.566785-2-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Ming Lei authored and gregkh committed Aug 3, 2023
1 parent e2e4bc5 commit 6ab3e7d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/block/ublk_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,8 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd)
if (ublksrv_pid <= 0)
return -EINVAL;

wait_for_completion_interruptible(&ub->completion);
if (wait_for_completion_interruptible(&ub->completion) != 0)
return -EINTR;

schedule_delayed_work(&ub->monitor_work, UBLK_DAEMON_MONITOR_PERIOD);

Expand Down

0 comments on commit 6ab3e7d

Please sign in to comment.