Skip to content

scsi: target: keep command bytes inside the sg

Jia Jia linux-scsi lkml target-devel 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 0 repliesNew
  2. v18 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- 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.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8scsi: target: take COMPARE AND WRITE data from the write halfdrivers/target/target_core_sbc.c drivers/target/target_core_transport.c+80 -310 replies
2/8scsi: target: keep REPORT REFERRALS stores inside the bufferdrivers/target/target_core_alua.c+19 -40 replies
3/8scsi: target: reject a short SET TARGET PORT GROUPS listdrivers/target/target_core_alua.c+3 -30 replies
4/8scsi: target: copy a DIF insert tuple across prot sgsdrivers/target/target_core_sbc.c+131 -490 replies
5/8scsi: target: copy a DIF verify tuple across prot sgsdrivers/target/target_core_sbc.c+58 -540 replies
6/8scsi: target: limit DIF block CRC to each data sgdrivers/target/target_core_sbc.c+42 -120 replies
7/8scsi: target: keep pscsi mode bytes inside the data sgsdrivers/target/target_core_pscsi.c+17 -200 replies
8/8scsi: target: advance past escaped DIF blocks across data sgsdrivers/target/target_core_sbc.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/8] scsi: target: keep command bytes inside the sg

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(-)