Re: [PATCH] ublk: reset kernel-owned dev_info fields in ublk_ctrl_add_dev()

Jens Axboe <[email protected]> Mon, 27 Jul 2026 11:09:03 -0600
Newsgroups org.kernel.vger.linux-block,org.kernel.vger.stable
Message-ID <178517214380.2192703.14950200230738719801.b4-ty@b4>
On Sun, 26 Jul 2026 09:50:25 -0500, Ming Lei wrote:
> ublk_ctrl_add_dev() memcpy()s the userspace ublksrv_ctrl_dev_info into
> ub->dev_info and then fixes up the fields the driver owns, but misses
> ->state and ->ublksrv_pid.
> 
> A device added with ->state = UBLK_S_DEV_LIVE passes the
> "->state != UBLK_S_DEV_DEAD" test that ublk_stop_dev_unlocked() uses as its
> proxy for "a disk is attached", while ->ub_disk is still NULL, so DEL_DEV
> right after ADD_DEV oopses in del_gendisk().  UBLK_S_DEV_QUIESCED plus
> UBLK_F_USER_RECOVERY dies one step earlier, in ublk_force_abort_dev().  A
> poisoned ->state also gets START_USER_RECOVERY and the char device
> read/write path onto a device that was never started, and wedges START_DEV
> at -EEXIST.  A poisoned ->ublksrv_pid just makes GET_DEV_INFO report an
> unrelated task as the ublk server.
> 
> [...]

Applied, thanks!

[1/1] ublk: reset kernel-owned dev_info fields in ublk_ctrl_add_dev()
      commit: e65848e4ce352bac9e3465099354c8b8f845391f

Best regards,
-- 
Jens Axboe