Skip to contentSkip to conversation

scsi: scsi_debug: fix one-partition tape setup bounds

PATCH Applied Samuel Moelius 3 participants 4 messages Jun 4 – Jun 16 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 scsi: scsi_debug: fix one-partition tape setup bounds

The tape setup path uses one tape_block entry as the end-of-data marker after the usable tape blocks. For the one-partition layout, partition 0 uses all TAPE_UNITS data slots and partition 1's marker is written at tape_blocks[0] + TAPE_UNITS.

Only TAPE_UNITS entries are allocated, so that marker write is one element past the allocation during device initialization before any command is issued.

Allocate one extra tape_block entry for the marker. This keeps the existing partitioning paths unchanged while providing backing storage for the sentinel.

Assisted-by Codex:gpt-5.5-cyber-preview

---
Changes in v3
- Use TAPE_UNITS + 1 approach
Changes in v2
- Fixed handling of part_1_size == 0 case

 drivers/scsi/scsi_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +1 -1
index 1515495fd9ea..38fedfa3cefe 100644
@@ -6648,7 +6648,7 @@ static int scsi_debug_sdev_configure(struct scsi_device *sdp,
 	if (sdebug_ptype == TYPE_TAPE) {
 		if (!devip->tape_blocks[0]) {
 			devip->tape_blocks[0] =
-				kzalloc_objs(struct tape_block, TAPE_UNITS);
+				kzalloc_objs(struct tape_block, TAPE_UNITS + 1);
 			if (!devip->tape_blocks[0])
 				return 1;
 		}
Signature · 1 line
2.43.0
Reviewed-by Kai Mäkisara on v3 1/1
#1 lore raw
Quoted 17 lines · Samuel Moelius

The tape setup path uses one tape_block entry as the end-of-data marker after the usable tape blocks. For the one-partition layout, partition 0 uses all TAPE_UNITS data slots and partition 1's marker is written at tape_blocks[0] + TAPE_UNITS.

Only TAPE_UNITS entries are allocated, so that marker write is one element past the allocation during device initialization before any command is issued.

Allocate one extra tape_block entry for the marker. This keeps the existing partitioning paths unchanged while providing backing storage for the sentinel.

Quoted 5 lines
Assisted-by Codex:gpt-5.5-cyber-preview

---
Changes in v3
- Use TAPE_UNITS + 1 approach

Reviewed-by Kai Mäkisara <[email protected] <mailto:[email protected]>>

Thanks, Kai

#2 lore raw
In reply to Samuel Moelius

Samuel,

Quoted 4 lines

The tape setup path uses one tape_block entry as the end-of-data marker after the usable tape blocks. For the one-partition layout, partition 0 uses all TAPE_UNITS data slots and partition 1's marker is written at tape_blocks[0] + TAPE_UNITS.

Applied to 7.2/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
#3 lore raw
In reply to Samuel Moelius
Quoted 10 lines · Samuel Moelius

The tape setup path uses one tape_block entry as the end-of-data marker after the usable tape blocks. For the one-partition layout, partition 0 uses all TAPE_UNITS data slots and partition 1's marker is written at tape_blocks[0] + TAPE_UNITS.

Only TAPE_UNITS entries are allocated, so that marker write is one element past the allocation during device initialization before any command is issued.

[...]

Applied to 7.2/scsi-queue, thanks!

[1/1] scsi: scsi_debug: fix one-partition tape setup bounds

      https://git.kernel.org/mkp/scsi/c/3c08f6034d74
Signature · 1 line
Martin K. Petersen