From: Yingjie Wang <x-professor@outlook.com>
To: "Martin K. Petersen" <mkp@kernel.org>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
Bart Van Assche <bvanassche@acm.org>,
Yang Xiuwei <yangxiuwei@kylinos.cn>,
James Houghton <jthoughton@google.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH v5 0/4] scsi: Release completed passthrough requests before user copyback
Date: Sat, 21 Nov 2026 08:27:14 +0000 [thread overview]
Message-ID: <scsi-sync-v5.1795249365940711260.0.x-professor@outlook.com> (raw)
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 access faults and needs I/O from the same queue, the
task can wait for a tag held by the request it would release only after
the fault returns.
Each patch saves the completion state needed for copyback, releases the
request, then performs the user access:
1/4 SG_IO on a SCSI block device
2/4 the legacy SCSI_IOCTL_SEND_COMMAND ioctl
3/4 CDROMREADAUDIO through sr_read_cdda_bpc()
4/4 the synchronous BSG ioctl
This series addresses the completion side only. As Bart pointed out,
these paths also access user memory after allocating a request and
before submitting it. Without an I/O scheduler, that request already
holds a driver tag, so a fault needing I/O from the same exhausted tag
pool can encounter a similar dependency. The submission-side ordering
is unchanged here.
Moving CDB copies before request allocation would not address faults
in blk_rq_map_user*(), which needs an allocated request. Addressing
that dependency requires a different approach and is outside this
series.
Changes in v5:
- Document that scsi_complete_sghdr_rq() frees its request, as requested
by Bart Van Assche.
- Set rq to NULL after the legacy ioctl's early free and use conditional
cleanup, removing the extra success-path goto, as suggested by Bart.
- Clarify the completion-side scope and tag dependency. Patches 3 and 4
have no functional changes.
Tested on 9f9e0b1e5399 with QEMU, a virtio-scsi disk and CD-ROM,
KASAN and lockdep. The base and v5 each passed 960 regression checks,
including 220 synchronous checks. Tracing covered 100 synchronous
windows: 80 showed v5 releasing the request before unmapping, while
the base retained it; 20 checked legacy ioctl execution and release.
CDDA coverage exercised EIO and release ordering, not successful audio
extraction. The unchanged io_uring path still retained its request
until task work, as expected. No page-fault deadlock was reproduced.
Each patch passed an x86_64 W=1 build of the affected objects. Kernel
selftests were not run.
The BSG io_uring completion fix remains a separate two-patch series,
which applies on top of these four patches.
v4: https://lore.kernel.org/r/cover.1794990780.git.x-professor@outlook.com
RFC v3: https://lore.kernel.org/r/cover.1794045010.git.x-professor@outlook.com
Bart's scope question:
https://lore.kernel.org/r/3dcb1a44-6e99-4d34-9b49-675d98c90da1@acm.org
Yingjie Wang (4):
scsi: core: Release SG_IO request before user copyback
scsi: core: Release legacy ioctl request before user copyback
scsi: sr: Release CDDA request before user copyback
scsi: bsg: Release synchronous request before user copyback
drivers/scsi/scsi_bsg.c | 23 ++++++++++++++--------
drivers/scsi/scsi_ioctl.c | 41 ++++++++++++++++++++++++++++-----------
drivers/scsi/sr.c | 3 +++
3 files changed, 48 insertions(+), 19 deletions(-)
base-commit: 9f9e0b1e5399045982788a954d3461de894e40c7
--
2.43.0
next reply other threads:[~2026-11-21 8:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 8:27 Yingjie Wang [this message]
2026-11-21 8:27 ` [PATCH v5 1/4] scsi: core: Release SG_IO request " Yingjie Wang
2026-11-21 8:27 ` [PATCH v5 2/4] scsi: core: Release legacy ioctl " Yingjie Wang
2026-11-21 8:27 ` [PATCH v5 3/4] scsi: sr: Release CDDA " Yingjie Wang
2026-11-21 8:27 ` [PATCH v5 4/4] scsi: bsg: Release synchronous " Yingjie Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=scsi-sync-v5.1795249365940711260.0.x-professor@outlook.com \
--to=x-professor@outlook.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bvanassche@acm.org \
--cc=jthoughton@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=yangxiuwei@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®