ublk: check for ublk_unmap_io() returning 0

If the userspace ublk server passes an unmapped address as the data
buffer for a completed ublk read, ublk_unmap_io() will return 0
indicating no bytes could be copied. Currently, this will result in
calling blk_update_request() with nr_bytes=0, which doesn't seem
supported. Fail the I/O with BLK_STS_IOERR in this case instead.

Fixes: 71f28f3136 ("ublk_drv: add io_uring based userspace block driver")
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Link: https://patch.msgid.link/20260729171041.45061-3-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Caleb Sander Mateos
2026-07-29 11:10:40 -06:00
committed by Jens Axboe
parent 3831568792
commit 24fd370617

View File

@@ -1590,8 +1590,14 @@ static inline void __ublk_complete_rq(struct request *req, struct ublk_io *io,
*
* Re-read simply for this unlikely case.
*/
if (unlikely(unmapped_bytes < io->res))
if (unlikely(unmapped_bytes < io->res)) {
if (unlikely(!unmapped_bytes)) {
res = BLK_STS_IOERR;
goto exit;
}
io->res = unmapped_bytes;
}
/*
* Run bio->bi_end_io() with softirqs disabled. If the final fput