mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jia Jia <physicalmtea@gmail.com>
To: "Martin K . Petersen" <mkp@kernel.org>,
	Jan Engelhardt <jengelh@inai.de>, Hannes Reinecke <hare@suse.de>,
	James Bottomley <James.Bottomley@suse.de>,
	Akinobu Mita <akinobu.mita@gmail.com>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org, Jia Jia <physicalmtea@gmail.com>
Subject: [PATCH v2 0/8] scsi: target: keep command bytes inside the sg
Date: Wed, 18 Nov 2026 12:13:03 +0800	[thread overview]
Message-ID: <20261118041311.19011-1-physicalmtea@gmail.com> (raw)

This series fixes eight target-core accesses past command-buffer or sg
boundaries. vhost-scsi can supply guest buffers whose sg boundaries do
not coincide with command fields, logical blocks or protection tuples.

Patch 1 builds the COMPARE AND WRITE write sg table from the entries
that contain the write half.

Patch 2 limits each REPORT REFERRALS LBA store to the bytes remaining
in the response buffer.

Patch 3 rejects SET TARGET PORT GROUPS parameter lists that end in a
partial four-byte descriptor.

Patch 4 lets sbc_dif_generate() write an eight-byte protection tuple
split across protection sg entries.

Patch 5 lets sbc_dif_verify() read a tuple split across protection sg
entries and rejects a partial tuple at the end of the list.

Patch 6 limits each CRC update to the bytes available in the current
data sg in both DIF generation and verification.

Patch 7 checks buffer lengths and uses sg copies for the pscsi MODE
SENSE write-protect byte and tape MODE SELECT block descriptor.

Patch 8 makes sbc_dif_verify() advance past an escaped block spanning
multiple data sg entries.

Patches 1, 2, 3 and 7 are independent. The DIF patches 4, 5, 6 and 8 fix
separate bugs and are posted in that order: patch 4 can stand alone,
patch 5 uses its tuple-copy helper, and patch 6 builds on both. Patch 8
covers escaped blocks, which bypass the CRC walk.

Changes in v2:
- Keep data sg advancement before the escape check in patch 5.
- Retain the existing atomic page mappings in the DIF paths.
- Fix escape advancement with the existing cursor loop in patch 8.
- Use the existing sg copy helpers for pscsi mode data in patch 7.
- Correct the Fixes tags in patches 1, 3 and 5.
- Explain why PI generation reads an existing tuple before updating it.
- Shorten the commit descriptions and retain the relevant trace frames.

Jia Jia (8):
  scsi: target: take COMPARE AND WRITE data from the write half
  scsi: target: keep REPORT REFERRALS stores inside the buffer
  scsi: target: reject a short SET TARGET PORT GROUPS list
  scsi: target: copy a DIF insert tuple across prot sgs
  scsi: target: copy a DIF verify tuple across prot sgs
  scsi: target: limit DIF block CRC to each data sg
  scsi: target: keep pscsi mode bytes inside the data sgs
  scsi: target: advance past escaped DIF blocks across data sgs

 drivers/target/target_core_alua.c      |  29 ++-
 drivers/target/target_core_pscsi.c     |  37 ++-
 drivers/target/target_core_sbc.c       | 422 ++++++++++++++++++++++-----------
 drivers/target/target_core_transport.c |  11 +-
 4 files changed, 338 insertions(+), 161 deletions(-)

             reply	other threads:[~2026-11-18  4:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  4:13 Jia Jia [this message]
2026-11-18  4:13 ` [PATCH v2 1/8] scsi: target: take COMPARE AND WRITE data from the write half Jia Jia
2026-11-18  4:13 ` [PATCH v2 2/8] scsi: target: keep REPORT REFERRALS stores inside the buffer Jia Jia
2026-11-18  4:13 ` [PATCH v2 3/8] scsi: target: reject a short SET TARGET PORT GROUPS list Jia Jia
2026-11-18  4:13 ` [PATCH v2 4/8] scsi: target: copy a DIF insert tuple across prot sgs Jia Jia
2026-11-18  4:13 ` [PATCH v2 5/8] scsi: target: copy a DIF verify " Jia Jia
2026-11-18  4:13 ` [PATCH v2 6/8] scsi: target: limit DIF block CRC to each data sg Jia Jia
2026-11-18  4:13 ` [PATCH v2 7/8] scsi: target: keep pscsi mode bytes inside the data sgs Jia Jia
2026-11-18  4:13 ` [PATCH v2 8/8] scsi: target: advance past escaped DIF blocks across " Jia Jia

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=20261118041311.19011-1-physicalmtea@gmail.com \
    --to=physicalmtea@gmail.com \
    --cc=James.Bottomley@suse.de \
    --cc=akinobu.mita@gmail.com \
    --cc=hare@suse.de \
    --cc=jengelh@inai.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mkp@kernel.org \
    --cc=target-devel@vger.kernel.org \
    /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®