The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Yingjie Wang <x-professor@outlook.com>
To: "Martin K. Petersen" <mkp@kernel.org>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: "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 v4 0/4] scsi: release completed passthrough requests before user copyback
Date: Wed, 18 Nov 2026 08:33:06 +0000	[thread overview]
Message-ID: <cover.1794990780.git.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 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.

Each patch saves what the copyback still needs (the result, bounded
sense data and, where a user buffer is mapped, the BIO chain saved at
mapping time), releases the request, and then performs the user
copyback:

  1/4  SG_IO on a SCSI block device (scsi_ioctl.c)
  2/4  the legacy SCSI_IOCTL_SEND_COMMAND ioctl (scsi_ioctl.c)
  3/4  CDROMREADAUDIO through sr_read_cdda_bpc() (sr.c)
  4/4  the synchronous BSG ioctl (scsi_bsg.c)

Changes since RFC v3:

- Dropped the RFC tag and the io_uring half.  RFC v3 5/6 and 6/6
  changed the asynchronous BSG path; after review they are being
  reworked to use a completion-buffer pool owned by bsg and will be
  posted as a separate series.
- 1/4 to 4/4 are RFC v3 1/6 to 4/6, unchanged apart from rebasing onto
  9f9e0b1e5399 from 7.4/scsi-fixes, which applied without edits.

Testing on this tip and, for comparison, on the unpatched base, both
with KASAN and lockdep, in QEMU with a virtio-scsi disk and CD-ROM:

- 20 iterations of the existing regression pass 960 assertions on both
  kernels with no kernel warnings: 220 for the synchronous paths
  (SG_IO, SCSI_IOCTL_SEND_COMMAND, BSG and CDDA) and 740 for the
  io_uring path, which this series does not change.
- Tracing the 80 SG_IO, BSG and CDDA commands that map a user buffer
  shows the request freed before blk_rq_unmap_user() on this tip, and
  after it on the base kernel, in every case.  The legacy ioctl has no
  user mapping to trace, so it is covered by the functional assertions
  only.  These tests check the release order, not the hang itself.
- The CDDA cases exercise the virtual CD-ROM's expected error path, not
  audio extraction from real media.
- Each commit builds with W=1 on x86-64; the tip also builds on i386,
  which was not booted.

All four patches carry Fixes: d285203cf647 ("scsi: add support for a
blk-mq based I/O path.") and Cc: stable.

v1: https://lore.kernel.org/r/cover.1792237341.git.x-professor@outlook.com
v2: https://lore.kernel.org/r/cover.1793003363.git.x-professor@outlook.com
RFC v3: https://lore.kernel.org/r/cover.1794045010.git.x-professor@outlook.com

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   | 22 ++++++++++++++--------
 drivers/scsi/scsi_ioctl.c | 34 ++++++++++++++++++++++++----------
 drivers/scsi/sr.c         |  3 +++
 3 files changed, 41 insertions(+), 18 deletions(-)


base-commit: 9f9e0b1e5399045982788a954d3461de894e40c7
-- 
2.43.0


             reply	other threads:[~2026-11-18  8:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  8:33 Yingjie Wang [this message]
2026-11-18  8:33 ` [PATCH v4 1/4] scsi: core: release SG_IO request before user copyback Yingjie Wang
2026-11-18  8:33 ` [PATCH v4 2/4] scsi: core: release legacy ioctl " Yingjie Wang
2026-11-18  8:33 ` [PATCH v4 3/4] scsi: sr: release CDDA " Yingjie Wang
2026-11-18  8:33 ` [PATCH v4 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=cover.1794990780.git.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