Re: [PATCH v4 1/4] scsi: core: release SG_IO request before user copyback

From: Bart Van Assche

Date: Thu Nov 19 2026 - 16:36:18 EST


On 11/18/26 12:33 AM, Yingjie Wang wrote:
> Four synchronous SCSI passthrough paths copy data to userspace, or unmap
> a user buffer that needs copyback, while they still hold the completed
> request. If that user access faults and the fault needs I/O from the
> same queue, the task can wait for a tag held by the request it would
> only release after the fault returns.

Does the same dependency exist on the submission side? All four code
paths access user memory after scsi_alloc_request() has succeeded and
before blk_execute_rq() is called:
- sg_io() calls copy_from_user() from scsi_fill_sghdr_rq() and next
calls blk_rq_map_user_io().
- sg_scsi_ioctl() calls copy_from_user() twice.
- scsi_bsg_sg_io_fn() calls copy_from_user() and blk_rq_map_user().
- sr_read_cdda_bpc() calls blk_rq_map_user().

If no I/O scheduler has been selected, the request allocated by
scsi_alloc_request() already owns a driver tag. If the host has only
one tag and if any of the above user memory accesses triggers a page
fault that requires I/O on the same queue, isn't that the same deadlock
as the one this series fixes? Pinning a data buffer that is not yet
resident seems at least as likely to me as a fault during copyback.
With mq-deadline there are two scheduler tags for a queue depth of one
so a single nested I/O request can make progress in that case.

I have not tried to trigger this. If my analysis is correct, please
either fix the submission side too or mention in the cover letter that
this series only addresses the completion side.

Thanks,

Bart.